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.开发者_如何学编程
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.)
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)
I make no promises, but this sounds like a candidate for using Windows Workflow Foundation.
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).
The framework is .Net! :-) WCF for the communication and WF for the implementation. In .Net 4 these come together as a WCF Workflow Service.
精彩评论