title: System.Windows.Forms.Timer not firing
body: <p>I want to use a <code>System.Windows.Forms.Timer</code> to ensure that an event fires on the UI thread of an excel addin I'm creating. I construct the timer as follows:</p>
  
  <pre><code>private System.Windows.Forms.Timer _timer;
  
  private void ThisAddIn_Startup(object sender, System.EventArgs e)
  {
      Debug.WriteLine("ThisAddIn_Startup:" + Thread.CurrentThread.ManagedThreadId);
  
      _timer = new System.Windows.Forms.Timer();
      _timer.Tick += new EventHandler(TimerEventHandler);
      _timer.Interval = 500;            
  }
  </code></pre>
  
  <p>The timer is fired by a COM event from a library I am using:</p>
  
  <pre><code>private void OnEvent()
  {
      _timer.Start();
  }
  </code></pre>
  
  <p>I then expect the <code>_timer</code> to call the following method when it ticks:</p>
  
  <pre><code>public void TimerEventHandler(object sender, EventArgs args)
  {
      _timer.Stop();
      Debug.WriteLine("Tick: " + Thread.CurrentThread.ManagedThreadId);                  
  }
  </code></pre>
  
  <p>As I understand, when I create the timer in the Addin thread, even though it is started from another thread (COM event in this case), it should fire on the thread that it was created on, i.e. the addin thread. However, this doesn't happen.</p>
  
  <p>I have implemented this exact mechanism in an <code>RTDServer</code> I wrote in the past (<a href="http://weblogs.asp.net/kennykerr/archive/2008/11/13/Rtd3.aspx" rel="nofollow noreferrer">as outlined by Kenny Kerr</a>) and it works as expected but the <code>_timer</code> in this scenario never ticks.</p>
  
  <p>I have also read <a href="https://stackoverflow.com/questions/9525467/how-to-raise-an-event-from-an-object-that-uses-a-timer-back-to-the-ui-thread">other SO articles</a> that point to the same behavior and can't figure out what is different about my addin setup?</p>
  
  <p><strong>EDIT:</strong>
  The OnEvent() method is fired.</p>