title: Windows Forms Timer bug or bad use?
body: <p>When programming a small OpenGL application using Windows Forms, I discovered something using a profiler that I thought was pretty wonky.</p>
  <p>I'm using a <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx" rel="nofollow noreferrer">System::Windows::Forms::Timer</a> to detect a combination of mouse idling and some other user input.  The tick functionality is useful, but on occasion I want to 'reset' the timer. You can't really do this directly, but you get the correct effect by doing this:</p>
  <pre><code>this-&gt;someTimer-&gt;Stop();
  this-&gt;someTimer-&gt;Start();
  </code></pre>
  <p>The timer interval is 50ms. Sometimes my 'reset' code here is run every 30ms. To my surprise, this is a very taxing thing to do - 30% of my program execution is often in these two lines! And it isn't a case of calling these two lines too often. In certain contrived situations this code is called as often as <code>OpenGLSwapBuffers()</code> for example, but no more. I interpret this as meaning that these two lines cost roughly half as much my entire render loop!</p>
  <p>Currently I'm using a workaround, but the timer method is a little more elegant. I'm very curious - why are these two lines so computationally expensive? What am I missing? Is there a better way to reset a timer?</p>