During debugging I can see that after Timer.Stop() or Timer.Enabled = false commands are executed, Timer is still running (Timer.Enabled = true). How is that possible?
During debugging I can see that after Timer.Stop() or Timer.Enabled = false commands are
Share
This is possible when you stop the timer on a worker thread. For example:
Output:
True
The timer must be stopped by the UI thread, the class takes care of it automatically. Quite similar to Control.BeginInvoke(). There’s an explicit race, the Tick event handler can run after you stopped it. This can also happen on the UI thread if the very first timer you create is created on a worker thread. A splash screen for example. That’s not healthy, you ought to fix that.