Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Services Framework?

Are there any good frameworks or templates for developing Windows Services? I generally don't write windows services and hoping someone has shared their expertise via an api or example project.

I am working on a project with the following requirements:

    **A windows service that:**
  • performs 1..many independently scheduled tasks
  • reports on the success or failure of these tasks via email/log/sms/??
  • allows adding/removal of tasks
  • allows changing of schedules

UPDATE

marc_s answer reminded me of this 2005 Visual Studio Magazine article by Luther Miller that I read.

like image 544
dr. Avatar asked Sep 27 '10 16:09

dr.


4 Answers

I know this is an old question, but for the occasional Googler coming across this, as I have:

Topshelf is a nice Windows Services framework.

Creating Windows Services using the standard Windows Service Template in Visual Studio is simple enough, you don't really need any special framework. However, in VS Express you may not have the winservice template and then Topshelf makes it quite easy using the Windows -> Console Application project template.

There is no single framework that will provide all the requirements listed in the original question, but here are some suggestions:

  • many independently scheduled tasks
  • allows adding/removal of tasks
  • allows changing of schedules

You're probably pretty much on your own here, but it's easy enough to accomplish with timer(s) and simple configuration in your App.config. Or, if you want to be fancy, using dependency injection or a plugin mechanism, maybe using MEF.

  • reports on the success or failure of these tasks via email/log/sms/??

Look at log4net or NLog. Topshelf has support for both.

(Having used Windows Workflow Foundation (WF), I'm not convinced at all by the WF-related answers to this question. I would appreciate if anyone is able to provide references to reputable sample apps that show how WF could possibly address any of these requirements in the original question.)

like image 60
G. Lombard Avatar answered Oct 06 '22 14:10

G. Lombard


I make no promises, but this sounds like a candidate for using Windows Workflow Foundation.

like image 35
Randolpho Avatar answered Oct 06 '22 13:10

Randolpho


If it is a scheduler kind of thing that you are looking for, then you may want to look at Quartz.net. This is an open source job scheduling system. It would be easier to use an existing tool rather than rewriting one from scratch (unless it is for academic purposes).

like image 38
Josh Avatar answered Oct 06 '22 13:10

Josh


In terms of software, there's no need for anything other than the .NET base class library.

I found this two-part article very useful and enlightening, especially considering your requirement to "performs 1..many independently scheduled tasks....":

  • Creating an Extensible Windows Service (Part 1)
  • Creating an Extensible Windows Service (Part 2)
like image 42
marc_s Avatar answered Oct 06 '22 14:10

marc_s