views:

71

answers:

4

I have started working with the C# from couple of months and now i am starting with the windows service. MSDN is good as 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 ?

+3  A: 

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.
leppie
+2  A: 

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.

Kevin Won
I want something which get started when machine starts. That will spawn some threads and keep working in background. For this i only know service as option. Please let me know if there is other way for this; i am interested to use it if its nice.
Anil Namde
+1  A: 

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

Matt Davis