title: ObjectDisposedException - running stopwatch in GUI thread
body: <p>I have a stopwatch running in a different thread, that updates the GUI thread in a label to show as time goes by.  When my program closes, it throws a <code>ObjectDisposedException</code> when I call <code>this.Invoke(mydelegate);</code> in the Form GUI to update the label with the time from the stopwatch.  </p>
  
  <p>How do I get rid of this <code>ObjectDisposedException</code>?  </p>
  
  <p>I have tried to stop the stopwatch in the FormClosing Event, but it does not handle it. </p>
  
  <p>Here's the code:</p>
  
  <pre><code>System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
              stopwatch = sw;
  
              sw.Start();
              //System.Threading.Thread.Sleep(100);
              System.Threading.Thread t = new System.Threading.Thread(delegate()
              {
                  while (true)
                  {
                  TimeSpan ts = sw.Elapsed;
  
                  string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                  ts.Hours, ts.Minutes, ts.Seconds,
                  ts.Milliseconds / 10);
  
                  timeElapse = elapsedTime;
  
                    UpdateLabel();
                  }
              });
              stopwatchThread = t;
              t.Start();
  
   public void UpdateLabel()
          {
              db = new doupdate(DoUpdateLabel);
  
              this.Invoke(db);
          }
  
   public void DoUpdateLabel()
          {
              toolStripStatusLabel1.Text = timeElapse;
          }
  </code></pre>