Windows Service – adding timer

I have done it before – and I did again today… Used about an hour trying to figure out, why a service for Windows that I created using Visual Studio 2005 did’nt work at all. It started great, restartet – all was perfect – but it did’nt tick.

Until I finally found out the hard way, that you have to add a System.Timers.Timer timer instead of the Windows.Forms.Timer. I actually followed a guide somewhere on the Internet saying that I could just drag-n-drop the Timer from Components in the Service Project. But, it did’nt really help.

But what did help was adding this as the first line in the class:

Friend WithEvents tmrCheckShows As New System.Timers.Timer

And now the service is ticking – or elapsing.

Leave a Comment