The fourth of my Windows 7 development screencasts - Trigger Started Services
- has been published. It uses the recipe
(also recently published on Code Gallery) to simplify writing a service in managed code that starts only when it is notified by the operating system of a particular trigger. In my screencast I use the example of a USB device being plugged in. There are plenty of other triggers you could use. Adopting a trigger-started approach makes your service:
- easier to write and install. No sleeping, looping, having a config file to say how long to sleep for, etc.
- use less CPU when there's nothing to do
- respond more quickly when there's something to do. It's not in the middle of sleeping for 10 minutes or 2 hours -- it is started the moment the trigger happens.
It's a win all around and if you have a service you should take a look at the available triggers and see if you can convert yours.