Stopping a System.Threading.Timer


Sharing is Caring

Stopping a System.Threading.Timer isn’t very well covered in the MSDN documentation.

We need to use the Change Method which accepts two integers. Please note that it is possible that a few callbacks can be potentially queued and called after you have stopped the timer. This is because the callback of the System.Threading.Timer uses worker threads.

To stop the timer we use the following code in C#.NET

mytimer.Change(Timeout.Infinite, Timeout.Infinite);

Hope this helps.

Sharing is Caring