Does calling Timer.Dispose() prevent the timer from firing ?

  • Thread starter Thread starter Anuj Agarwal
  • Start date Start date
A

Anuj Agarwal

I would imagine the answer is yes and thats how i have it
in my code. Example - i start a timer waiting for user
input. If the user input occurs before the timeout, i call
Timer.Dispose on that timer to get rid of it and prevent
it from firing.

But every once in a while the timer will actually fire a
couple of seconds after user input.

Any ideas why that might be happening ?
 
Is there a reason youa re not using Timer.Stop() to stop the timer? (Or
Timer.Enabled = false)?
 
Sorry, i should have mentioned - i'm using
System.Threading.Timer not System.Timers. The one i'm
using doesn't have those functions. I don't have a
particular reason for using Threading.Timer. I guess i'll
take a look at the other one.
 
Back
Top