/// <summary> /// Initializes a new instance of <see cref="DelayedEventPublisher"/>. /// </summary> /// <param name="realEventHandler">The event handler which will be called when the timeout has elapsed.</param> /// <param name="timeoutMilliseconds">The timeout period, in milliseconds, for triggering the real event handler. The default is 350 ms.</param> /// <param name="trigger">Specifies when the real event handler is called after a period of inactivity, or periodically after the last event was raised. The default is to trigger on inactivity.</param> internal DelayedEventPublisherBase(EventHandler realEventHandler, int timeoutMilliseconds = DefaultTimeout, DelayedEventPublisherTriggerMode trigger = DefaultTrigger) { Platform.CheckForNullReference(realEventHandler, "realEventHandler"); Platform.CheckPositive(timeoutMilliseconds, "timeoutMilliseconds"); _realEventHandler = realEventHandler; _timeoutMilliseconds = Math.Max(10, timeoutMilliseconds); _trigger = trigger; _timer = new Timer(OnTimer); _timer.IntervalMilliseconds = 10; }
/// <summary> /// Disposes the <see cref="DelayedEventPublisher"/>. /// </summary> protected virtual void Dispose(bool disposing) { if (disposing && _timer != null) { _timer.Dispose(); _timer = null; } }