title: Stopping A Timer And Preventing The Elapsed Event To Fire
body: <p>From MSDN:</p>
  
  <blockquote>
    <p>The Timer.Elapsed event is raised on a ThreadPool thread, so the event-handling method might run on one thread at the same time that a call to the Timer.Stop method runs on another thread. This might result in the Elapsed event being raised after the Stop method is called..</p>
  </blockquote>
  
  <p>I have a timer that runs for a specific time then elapses and sets a flag.  Sometimes I want to stop the timer and restart it.</p>
  
  <p>Currently when I try to stop the timer, the elapsed event still fires (sometimes), so my flag is set when I don't want it to be.</p>
  
  <p>How do I stop the flag and be sure the elapsed event doesn't fire?</p>
  
  <p><em><strong></em>**EDIT**</strong></p>
  
  <p>In the event handler, I've tried checking the timer's state to ensure its enabled before I run the code, and I've also tried setting a flag when I stop the timer and checking that flag before running the code.</p>
  
  <p>Neither work</p>