.NET Windows Service with timer stops responding

Solution 1:

unhandled exceptions in timers are swallowed, and they silently kill the timer

wrap the body of your timer code in a try-catch block

Solution 2:

I have seen this before with both timer, and looped services. Usually the case is that an exception is caught that stops the timer or looping thread, but does not restart it as part of the exception recovery.

To your other points... I dont think that there is anything "elegant" about the timer. For me its more straight forward to see a looping operation in code than timer methods. But Elegance is subjective.

Memory issue? Not if you write it properly. Maybe a processor burden if your Thread.Sleep() isn't set right.

Solution 3:

http://support.microsoft.com/kb/842793

This is a known bug that has resurfaced in the Framework more than once.

The best known work-around: don't use timers. I've rendered this bug ineffective by doing a silly "while (true)" loop.

Your mileage may vary, so verify with your combination of OS/Framework bits.