Behaviour of System.Timer when Interval property changed

Posted by lowlyintern on Stack Overflow See other posts from Stack Overflow or by lowlyintern
Published on 2010-05-05T09:49:53Z Indexed on 2010/05/05 9:58 UTC
Read the original article Hit count: 164

Filed under:
|

I have a System.Timer setup to trigger an event every day at 2AM. If the process the timer starts fails then I want the timer to be reset to run every 15 minutes until the process completes succesfully.

// this is how the timer is set up. 
// this is working correctly.

double startTime = milliseconds_of_hour_to_start.

Timer = new System.Timers.Timer( startTime);

Here is the code to reset the timer on success or failure of the event handler. NOTE the timer is not being stopped, just the Interval property is being reset.

if (ProcessSuccess)
{
  Timer.Interval = TimeSpan.FromHours(24).TotalMilliseconds;
}
else
{
  Timer.Interval = TimeSpan.FromMinutes(15).TotalMilliseconds;
}

My question is this, if the process fails say 4 times, then succeeds will the Timer now be running at around 3AM? i.e. after failing will the original start time of 2AM be advanced by 15 minutes?

© Stack Overflow or respective owner

Related posts about timers

Related posts about .NET