/// <summary> /// Clears the list. Only errors that have been already raised by <see cref="OnErrorFromBackgroundThreads"/> /// are removed from the internal buffer: it can be safely called at any time. /// </summary> /// <param name="cleared">Number of suppressed errors.</param> /// <param name="waitingToBeRaisedErrors">The number of errors waiting to be raised.</param> public void Clear(out int cleared, out int waitingToBeRaisedErrors) { cleared = 0; lock ( _collector ) { // Items are from oldest to newest: take the index of the first one that has not been raised yet. int idx = _collector.IndexOf(e => e.SequenceNumber >= _lastSeqNumberRaising); if (idx < 0) { cleared = _collector.Count; waitingToBeRaisedErrors = 0; _collector.Clear(); } else { cleared = idx; waitingToBeRaisedErrors = _collector.Count - idx; _collector.Truncate(waitingToBeRaisedErrors); } } }
/// <summary> /// Clears the current <see cref="Entries"/> list. /// </summary> public void Clear() { _entries.Clear(); }