public void Paused() { Contract.Assert(!isPaused); if (ResumeEvent == null) { ResumeEvent = new ManualResetEvent(false); } else { ResumeEvent.Reset(); } Timer.Pause(); // Set IsPaused at the last as other threads seeing it set, will expect a valid // reset ResumeEvent. Also the requirement here is that only after Paused // returns other threads should block on this event. So there is a race condition here. isPaused = true; }
public void Pause() { ResumeEvent.Reset(); PauseEvent.Set(); }