/// <summary> /// Creates a new instance of the WaitTimer class. /// </summary> /// <param name="initialState">true to set the initial state to signaled; false to set the initial state to non-signaled.</param> /// <param name="autoReset">true for the wait handle to auto reset, false for manual reset.</param> public WaitTimer(bool initialState, bool autoReset) : base() { this.autoReset = autoReset; this.signaled = initialState; this.waitHandle = new AutoResetEvent(initialState); this.timer = new HighAccuracyTimer() { Resolution = 1, Mode = TimerMode.OneShot, }; this.timer.Elapsed += TimerElapsed; }
protected override void Dispose(bool explicitDisposing) { if (!this.disposed) { if (explicitDisposing) { this.waitHandle.Dispose(); this.timer.Dispose(); } this.waitHandle = null; this.timer = null; this.disposed = true; } base.Dispose(explicitDisposing); }