Home All Groups Group Topic Archive Search About

Timer ellapsed event triggered indefinitly

Author
27 Apr 2006 3:50 AM
Raphael
I'm having some problems with System.Threading.Timer used in a Windows
Service with the .NET Framework 1.1 SP1, the following C# code:

----------------------------------------------------------
public delegate void JobDelegate();

private Timer _timer;
static private TimeSpan OneDay = new TimeSpan (1, 0, 0, 0);
private JobDelegate _job;

protected void TimerElapsed (object args)
{
   _job.DynamicInvoke (null);
}

// That's the Windows Service Start() method
public void Start()
{
.... // Initialization of local variable 'dueTime'
    _timer = new Timer (new TimerCallback (TimerElapsed), null, dueTime,
OneDay);
}
----------------------------------------------------------

Works fine for about a month (that is the function referenced by the
delegate `_job' is called daily at 'dueTime') but suddenly, one day, will
cause the function referenced by the delegate `_job' to be called in what
seems to be an infinite loop until the service is stopped.

I'm aware of http://support.microsoft.com/kb/900822/ but this looks like  a
different problem (haven't installed the patch though).

Did anyone experience the same problem? Any Idea?

Thanks a lot,
Raphael.

AddThis Social Bookmark Button