views:

81

answers:

1

Hi there,

Having a few problems with Timers within a service on Win2k3... Basically, creating a service that every X minutes/seconds, checks for a certain process and whether it is running. I figured the easiest way to get this done was via a Timer, and so I coded all that in, and it seemed to be working OK.

Have managed to install the service fine, and it seems to be reporting that it is starting/stopping OK. I have written to the eventlog using Eventlog.WriteEntry, and have observed that it is reaching the startup function, but not the Timer Tick.

Is there a known fault with Win2k3 and Timers?
Am I doing something wrong?

            EventLog.WriteEntry("SETTINGS SET");
            // Set our timer's interval to the value set in the settings.xml file.
            tmrCheck.Interval = Int32.Parse(_settingChkInterval) * 1000;
            // Enable our timer and away we go, checking away!
            tmrCheck.Enabled = true;
            // Set our Tick event to our Tick void
            tmrCheck.Tick += new EventHandler(tmrCheck_Tick_1);
+1  A: 

Mmmm, you cant use a Winform timer in a service.

You need to use System.Timers.Timer or System.Threading.Timer.

leppie
Argh! It's the simplest errors that get us I guess.Thanks a lot bud.
Daniel May