/// <summary> /// Resumes all events after SuspendEvents. Automatically fires any pending events when appropriate. Implements reference counting to detect when to /// finally resume events, at which point the Resume event is fired. /// </summary> public void ResumeEvents() { // Lock changes lock (_syncRoot) { // Decrement counter, do nothing when still suspended if (--_suspendEventsCount > 0) { return; } // Call method on all items foreach (var item in Items) { item.ResumeEvents(); } // Fire event EventsResumed?.Invoke(this, EventArgs.Empty); } }
/// <summary> /// Called when events are resumed the last time, i.e. is not fired when nested. /// Fires the <see cref="EventsResumed"/> event. /// </summary> protected virtual void OnEventsResumed() { // Fire event EventsResumed?.Invoke(this, EventArgs.Empty); }