开发者

starting windows service development using .net

I have started working with the C# from couple of months and now i am starting with the windows service. MSDN is good 开发者_如何学Goas always to start with but i would like to know if there is book, blog ... etc (dedicated) for this which could be a nice starting point ?


I found the following useful to me when I started making services:

  • Devhood - Creating a Windows Service with C#
  • Grinn Blog - Windows Services in C#: Part 1: Programming a Windows Service in C#
  • Developer.com - Creating a Windows Service in .NET


It the same as a console app, just without a console (and a little extra setup).

I have written many console apps that can run as a service too, you can achieve this in less than 5 lines of code.

Your best bet is just to use the default VS template for a service, and see how little difference there really is.

There are some things to watch out for however.

  • Your service needs to do something, else it will just exit after starting. I normally just start off another thread with the workload.
  • You need to be able to stop your service. Using a thread as above provides an ugly but foolproof way.
  • Services can't (or should not) interact with the desktop.


What is the reason for choosing windows services as you execution environment? Generally, these are avoided if possible (particularly for people new to .NET). They can be sort of cranky and are rather opaque. By all means, if your requirements neccesatate a windows service, go for it, but if not, I'd start elsewhere.


If you want to create a Windows service using C# with Visual Studio 2008, you can follow the step-by-step instructions here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜