views:

136

answers:

3

Hello, I have to create an app that will read in some info from a db, process the data, write changes back to the db, and then send an email with these changes to some users or groups. I will be writing this in c#, and this process must be run once a week at a particular time. This will be running on a Windows 2008 Server.

In the past, I would always go the route of creating a windows service with a timer and setting the time/day for it to be run in the app.config file so that it can be changed and only have to be restarted to catch the update.

Recently, though, I have seen blog posts and such that recommend writing a console application and then using a scheduled task to execute it.

I have read many posts talking to this very issue, but have not seen a definitive answer about which process is better.

What do any of you think?

Thanks for any thoughts.

+6  A: 

If it is a one per week application, why waste the resources for it to be running in the background for the rest of the week.

A console application seems much more appropriate.

The typical rule of thumb that I use is something along these lines. First I ask a few questions.

  1. Frequency of Execution
  2. Frequency of changes to #1
  3. Triggering Mechanism

Basically from here if the frequency of execution is daily or less frequent I'll almost always lean towards a scheduled task. Then looking at the frequency for changes, if there is a high demand for schedule changes, I'll also try to lean towards scheduled tasks, to allow no-coding changes for schedule changes. lastly if there is ever a thought of a trigger other than time, then I'll lean towards windows services to help "future proof" an application. Say for example the requirement changes to be run every time a user drops a file in X folder.

Mitchel Sellers
I agree about using up the server resources. I think this is the direction I will go.Thanks
czuroski
+2  A: 

If you have only one application and you need it to run once a week may be scheduler will be good as there is no need to have separate service and process running on the system which will be idle most of the time.

Incognito
+4  A: 

The basic rule I follow is: if you need to be running continuously because events of interest can happen at any time, use a service (or daemon in UNIX).

If you just want to periodically do something, use a scheduled task (or cron).

The clincher here is your phrase "must be run once a week at a particular time" - go for a scheduled task.

paxdiablo
That's what I thought. As I had been reading through posts, that was the feeling I got towards doing this. i will give it a try.Thanks
czuroski