Timer in Windows Service fires eratically when interval elapsed

  • Thread starter Thread starter Roland
  • Start date Start date
R

Roland

Hi,

I have written a Windows Service with a Timer (System).
The Interval is set to 60000 (60 seconds) for testing.
In the Timer1_Elapsed event I execute a task.

In this case I have to read a text file, draw data from a SQL server,
and send it all out in an email every day at the same time.

Problem is that the elapsed event fires anywhere from 1 time to 40
times per interval. Subsequently, my task runs n times.

Is it possible to have it fire only once?
Or, stop it from firing until the next interval?

Thank you!

Roland
 
Roland said:
Hi,

I have written a Windows Service with a Timer (System).
The Interval is set to 60000 (60 seconds) for testing.
In the Timer1_Elapsed event I execute a task.

In this case I have to read a text file, draw data from a SQL server,
and send it all out in an email every day at the same time.

Problem is that the elapsed event fires anywhere from 1 time to 40
times per interval. Subsequently, my task runs n times.

Is it possible to have it fire only once?
Or, stop it from firing until the next interval?

Thank you!

Roland

I've had some arguments with the System.Timer but I've also built a
stable service that runs for about a year based on the System.Timer.

I suggest to take a look at the System.Threading.Timer, a little bit
more complex nut very reliable.

Just Google 'MSDN System.Threading.Timer' and check out the reference.

--

//Rutger

DoDotNet@KICKTHIS_Gmail.com
www.RutgerSmit.com
 
Back
Top