Task Scheduler vs Windows Service

It is not uncommon in a project where in we need to schedule some operation. It might be some database call or a webservice call or some simple call to a dll. There are several options one might consider in such a situation.

  • Create a Windows Service (background process) with a Timer which would initiate the operation at regular intervals as specified to the Timer.
  • Create a task in the Windows Task Scheduler which would initiate the application.
  • Create a timer in the global.asax file which would fire at regular intervals to initiate the required operation.
  • If the operation is about reading and writing to a SQL database, then SQL CLR integration can also be considered. Here SQL jobs could be used to call a procedure which calls the managed dll.

The project which I worked on required a similar functionality where a scheduler needed to call my dll which in turn would do the required webservice calls and some database operations. Me and my team went through several discussions about which option suits the best for our needs. Following were the highlights of the discussion –:

  • Windows Service is a nice option since it has inbuilt logging features and can gracefully handle failures. They are really easy to write ( We were working with .NET). The biggest constraint is writing a scheduler. We needed the operation to occur on a specific day at a specific time. Now we could have written a scheduler with lots of efforts, but if we needed to change the schedule we would have had to change the scheduler parameters somehow. Well a config file can help here but again, it is a technical task and certainly some normal Windows User (non technical) would not know these things by default.
  • Windows has a well tested Task Scheduler which can be used to schedule applications to be run at specific intervals. The scheduler is very usable and has pretty good granular control. Although to schedule tasks within seconds once would require to do some trick but we did not want that level of granularity. After rummaging in the cloud we found that once a password of the user Windows account changes, the task needs to be updated with the new credentials. This is kind of an admin task but pretty irritating. Although since with the task scheduler we would be running the application only when needed and not causing a resource hog like a Windows Service. Just to mention though, Windows Task Scheduler is actually implemented as a Service in Windows OS. There are some reports saying that the scheduler is a poorly written application and causes to fail several times.
  • A timer in the global.asax file also has the same problem of writing our scheduler. It also causes a needless dependency on the IIS server.
  • SQL CLR is a pretty compact option, but me and my team were not completely familiar with writing managed code in SQL and we had to come up with a cheap option in a small time frame.

We finally decided to go with the Windows Task Scheduler. Our application was really simple, it just had few function calls to our core engine which in turn took care of the webservice and database calls. So we did not have much worry about the logging features absent since we could write our own. In turn we got a well tested and easily usable scheduler and an application which ran only when needed.

You can try to find information about such a situation, you would stumble over lots of blogs stating one is better than the other and vice versa. Mostly people have chosen between a Service and the Windows Scheduler, but honestly it depends on the requirements of your application. For few hours I was hanging in limbo, between Service and Windows Scheduler but some of the blogs like Jon Galloway’s blog post helped me make my decision. I state again that our decision of Windows Task Scheduler was based on the information we could gather and our requirements more importantly.

Happy Programming!

8 Comments:

Anonymous said...

Using Windows Service with Quartz.NET scheduler is most flexible in my opinion...See: http://quartznet.sourceforge.net/

Abhang Rane said...

Looks interesting. Thanks for this!

Vee Eee Technologies said...

Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.

Anglina Williams said...

I read your blog great post. Thanks for advise .We also provide the Task Scheduling Software service . Keep sharing such knowledgeable post. Thanks.

Anonymous said...

Task scheduler control for Windows

Joseph C. Bartlett said...

MexNetwork have a variety of services and aptly trained staff ready to take your brand to the next level. Our wide range of services and solutions include: SEO Services , Administration and maintenance of social networks (Social Media) , administration and maintenance of servers , E-mail marketing , Marketing PPC (pay-per-click) . Do not stay out and uses the benefits that our package of services can provide your company.

Top Branding Agency in Mumbai said...

Thank you for sharing this informative post.

softclick said...


internet is a standard purpose development platform. it can be used for any kind of app type or workload wherein standard reason solutions are used. It has numerous key capabilities that are appealing to many developers, inclusive of computerized memory management and modern programming languages, that make it easier to efficaciously construct exquisite apps. multiple implementations of .net are available, primarily based on open .net requirements that specify the fundamentals of the platform
each it software program answers have professional for developing .net programmes we have professional crew for developing .internet programmes it support

Post a Comment