On a couple of occasions I have had to cook up a really basic Windows service using C#. I'm a fan of really really simple software, so a template that contains everything you need to run a basic service is ideal for me.
I hacked this together out of a few examples and it's been useful enough for me that I figured it was a good idea to share.
The project is currently empty, but it's trivial to add your own long running task/thread.
Simply locate OnStart() and OnStop() in HostService.cs, and start your thread/task at the appropriate location indicated by the
Once built, the project can be run or installed from a command line as follows:
--c | --console => run as console --i | --install => install as service --u | --uninstall => uninstall service
Source is available below, hope you find it as useful as I have!
Credit where it's due (the genius Marc Gravell)