System.Timers.Timer bug : timer fires immediately/continously

F

felix

In my application I have code something like:

protected System.Threading.Timer timer;

// called once on application boot
Init()
{
DateTime dueTime = DateTime.Now.AddDays(1); // in 24 hours
TimeSpan period = new TimeSpan(1, 0, 0, 0); // one day

timer = new System.Threading.Timer(
new System.Threading.TimerCallback(OnTimer),
null,
dueTime,
period);
}

// called when the timer fires
private void OnTimer(object state)
{
Console.Out.WriteLine("timer fired");

// ... do some work ...
}

After some time (many days) the timer event fires continuously, or
perhaps every second or so. If I restart the application, this behavior
continues. The only rememdy is to reboot windows!

I believe that there is a bug in the Timer class that causes it to quit
working after windows has been running for 2^31 ms (approximately 20
days).

If true, the enormity of this bug is quite huge, as it would affect a
huge class of .NET programs in almost certainly devastating ways.

Preliminary research brought me to the following newsgroup posts (watch
for wrapping):

http://groups-beta.google.com/group...q=dotnet+timer+reboot&rnum=5#365950ed5b37e205

http://groups-beta.google.com/group...net+timer+immediately&rnum=2#8ab9edfe727e79a6

Anyone have any more knowledge, ideas, or thoughts? I could not find
mention of this in the msdn knowledge base.

Thanks in advance,

Felix
 
G

Guest

Hi Felix,

i have the same problem wir System.Timers.Timer in Windows Service
Application.
Do you get feedback?
My Windows Services running over 2 Weeks without any problem. But anytime
they are flipping and fire x-times in one seccond.
A restart of the Services does't work. only a reboot of the w2k3 Server
 

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

Top