Reliably stop System.Threading.Timer?

An easier solution might to be to set the Timer never to resume; the method Timer.Change can take values for dueTime and period that instruct the timer never to restart:

this.Timer.Change(Timeout.Infinite, Timeout.Infinite);

Whilst changing to use System.Timers.Timer might be a “better” solution, there are always going to be times when that’s not practical; just using Timeout.Infinite should suffice.

Leave a Comment