Timer in Windows Service fires eratically when interval elapsed

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
 
R

Rutger Smit

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top