public Add ( |
||
ex | The unexpected exception. Must not be null. | |
comment | string | Comment associated to the error (such as the name of the culprit). Can be null. |
return | void |
public void Add( Exception ex, string comment )
{
if( ex == null ) throw new ArgumentNullException( "ex" );
if( _lostErrorCount > 1024 ) return;
if( comment == null ) comment = String.Empty;
lock( _collector )
{
if( _waitingRaiseCount >= _collector.Capacity )
{
Interlocked.Increment( ref _lostErrorCount );
return;
}
Interlocked.Increment( ref _waitingRaiseCount );
_collector.Push( new Error( comment, ex, _seqNumber++, _lostErrorCount ) );
}
if( Interlocked.CompareExchange( ref _dispatchWorkItemIsReady, 1, 0 ) == 0 )
{
Interlocked.Increment( ref _dispatchQueuedWorkItemCount );
ThreadPool.QueueUserWorkItem( DoRaiseInBackground );
}
else
{
Interlocked.Increment( ref _savedDispatchQueuedWorkItemCount );
}
}
LogFilter DoGetBoundClientMinimalFilter() { Debug.Assert(_enteredThreadId == Thread.CurrentThread.ManagedThreadId); LogFilter minimal = LogFilter.Undefined; List <IActivityMonitorClient> buggyClients = null; foreach (var l in _output.Clients) { IActivityMonitorBoundClient bound = l as IActivityMonitorBoundClient; if (bound != null) { try { minimal = minimal.Combine(bound.MinimalFilter); if (minimal == LogFilter.Debug) { break; } } catch (Exception exCall) { CriticalErrorCollector.Add(exCall, l.GetType().FullName); if (buggyClients == null) { buggyClients = new List <IActivityMonitorClient>(); } buggyClients.Add(l); } } } if (buggyClients != null) { foreach (var l in buggyClients) { _output.ForceRemoveBuggyClient(l); } } return(minimal); }