12

I am planning to create a utility, which will query the database and store some information (on another table in the database). Its a multi-threaded utility and require to run for every 5 or 10 minutes/later may be thrice in a day.

I see two options to achieve this in C#/DotNet programming.

  • creating windows service having timer approach inside it.
  • a console program and schedule it using windows task scheduler.

Which one do you prefer and why?

12
  • 3
    I think this question is better suited for SO
    – Naveen
    Commented Sep 22, 2010 at 5:03
  • 1
    Really, that's a good software design question and you'll likely have at least five good answers in five hours once you ask it on SO.
    – sharptooth
    Commented Sep 22, 2010 at 5:47
  • 1
    I voted to close, this actually belongs on SO Commented Sep 22, 2010 at 6:19
  • 2
    This question elicits a subjective and/or extended discussion on the merits of either. It's very much on topic here and subjective and argumentative there.
    – user8
    Commented Sep 22, 2010 at 8:23
  • 3
    I'm not sure, I think the last sentence "Which one do you prefer and why?" would trigger the close-bots over there. Its better here since actual answers can be got here
    – TheLQ
    Commented Sep 22, 2010 at 22:23

5 Answers 5

3

Comments from a colleague of mine from yesterday regarding this very same topic

"there is always going to be a varied opinion on this one... My rule of thumb would be if you need something that runs every five minutes (and you dont care what time it runs or how long a run takes) or something that responds to events, use a service. If you need something to run at a particular time each day and you are sure that there will not be an over lap, use the Scheduler provided with the OS. If you need a hybrid, either use both solutions for the varying cases or find something off the shelf. (Possibly Quartz .Net) "

Jon Galloway's article from 2005 "//TODONT: Use a Windows Service just to run a scheduled process" is a good read. I suggest that the comments also be read because the discussion still continues till today and provide some good counter-arguments as well.

Personally, I agree with my colleague on this one. Keep it simple for as long as possible. And if you are deploying to Win2008 server, check out the Task scheduler and all the features the standard scheduler offers. For me, the killer was to start a scheduled task when an event occurs.

5

Services are either used for administrative purposes or to offer a service to multiple applications.

Schedules are used for running a task multiple times which don't necessarily require extra permissions.

3

I've heard the arguments for using Windows Scheduler but have always opted for writting my app as a service. At first I thought it would be a better solution in a clustered environment but that's not really true. The bottom line is I didn't have a good reason other than it "felt" like better design.

0

why don't you try Quartz.net
i used it once and i can say it's a powerful framework to create you own scheduler, and it provide a pre builded Service that will run your scheduled Job's (stored in database or just in a XML file) http://quartznet.sourceforge.net/

1
  • 3
    -1 This does not answer the question at all and would fit better as a comment. Commented Sep 22, 2010 at 12:18
0

If you want the user to have more control without you having to build it, use the Task Scheduler. Looks like Google does this with their apps update. Depending on the user, it's not difficult manage the task. Take the user out of the loop and create a service. Most people will never touch them.

Not the answer you're looking for? Browse other questions tagged or ask your own question.