title: Dispose WaitOne function stuck timer callback
body: <p>I have a timer that it's callback do somethings: </p>
  
  <p>The timer:</p>
  
  <pre><code>dataProcessingTimer = new System.Threading.Timer(new TimerCallback(DataProcessingTimerHandler), null, 0, _dataProcessingTimerPollingInterval);
  </code></pre>
  
  <p>The callback:</p>
  
  <pre><code>void DataProcessingTimerHandler(object param)
  {
      // some code.. (sometimes the stop function called from here).
  }
  </code></pre>
  
  <p>When I want to stop the timer I called my stop function : </p>
  
  <pre><code>public void Stop()
  {
  
      if (_dataProcessingTimer != null)
      {
           ManualResetEvent timerDisposeHandler = new ManualResetEvent(false);
           _dataProcessingTimer.Dispose(timerDisposeHandler);
           _dataProcessingTimer = null;
  
           timerDisposeHandler.WaitOne();
      }
  
  }
  </code></pre>
  
  <p>The <code>timerDisposeHandler.WaitOne();</code> use for sure the dispose is done befoer the code that follows the stop function.</p>
  
  <p>But sometimes when the stop function is call in the middel of callback the waitone stuck all. </p>
  
  <p>It's seem that the WaitOne stuck the callback but I don't understand why it's happening, is the timer callback is not found in its own thread? why the thread of the stop function should stuck it?</p>
  
  <p>I would love if someone could explain to me the situation and give me a solution.</p>