title: Timer cannot be stopped in C#
body: <p>I have a timer on a windows form (C# 3.0, .net 3.5 SP1, VS2008 SP1, Vista) that seems to work even after it is stoppped. The code is:</p>
  
  <pre><code>using System;
  using System.Windows.Forms;
  
  namespace TestTimer
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
              StartTimer();
          }
  
          private DateTime deadline;
  
          private void StartTimer()
          {
              deadline = DateTime.Now.AddSeconds(4);
              timer1.Start();
          }
  
          private void timer1_Tick(object sender, EventArgs e)
          {
              int secondsRemaining = (deadline - DateTime.Now).Seconds;
  
              if (secondsRemaining &lt;= 0)
              {
                  timer1.Stop();
                  timer1.Enabled = false;
                  MessageBox.Show("too slow...");
              }
              else
              {
                  label1.Text = "Remaining: " + secondsRemaining.ToString() + (secondsRemaining &gt; 1 ? " seconds" : " second");
              }
          }
      }
  }
  </code></pre>
  
  <p>Even after the timer1.Stop() is called, I keep reeciving MessageBoxes on the screen. When I press esc, it stops. Howevere, I've expected that only one message box appears... What else should I do? adding timer1.Enabled = false does not change the behavior.</p>
  
  <p>Thanks</p>