This is possible when you stop the timer on a workflow. For instance:
public partial class Form1 : Form { public Form1() { InitializeComponent(); } Timer timer1; protected override void OnLoad(EventArgs e) { base.OnLoad(e); timer1 = new Timer(); timer1.Interval = 3000; timer1.Start(); var t = new System.Threading.Thread(stopTimer); t.Start(); } private void stopTimer() { timer1.Enabled = false; System.Diagnostics.Debug.WriteLine(timer1.Enabled.ToString()); } }
Output:
True
The timer must be stopped by the user interface thread, the class automatically executes it. Just like Control.BeginInvoke (). There is a clear race, the Tick event handler can work after you stop it. This can also happen in the user interface thread if the very first timer you create is created in the workflow. For example, a screen saver. This is not great, you have to fix it.
source share