C# 클래스 CK.Core.CriticalErrorCollector

This collector keeps Capacity Errors (and no more). It raises OnErrorFromBackgroundThreads event on each Add. It is totally thread-safe and guaranties (as long as its Capacity is big enough) that no error can be lost (even errors raised while dispatching the event are themselves collected) and that errors are dispatched in sequence.

This class is typically used as a static property or field by any object that must handle unexpected errors. (It can also be used per-instance if it makes sense.)

파일 보기 프로젝트 열기: Invenietis/ck-core 1 사용 예제들

공개 메소드들

메소드 설명
Add ( Exception ex, string comment ) : void

Adds a critical, unexpected error.

Clear ( ) : void

Clears the list. Only errors that have been already raised by OnErrorFromBackgroundThreads are removed from the internal buffer: it can be safely called at any time.

Clear ( int &cleared, int &waitingToBeRaisedErrors ) : void

Clears the list. Only errors that have been already raised by OnErrorFromBackgroundThreads are removed from the internal buffer: it can be safely called at any time.

CriticalErrorCollector ( ) : System

Initializes a new CriticalErrorCollector with a default Capacity set to 128.

DoRaiseInBackground ( object unusedState ) : void
ToArray ( ) : Error[]

Obtains a copy of the last (up to) Capacity errors from oldest to newest. The newest may have not been raised by OnErrorFromBackgroundThreads yet.

WaitOnErrorFromBackgroundThreadsPending ( ) : void

Blocks the caller thread until no more event is waiting to be raised by OnErrorFromBackgroundThreads or is being processed. This is the right function to use instead of pooling OnErrorFromBackgroundThreadsPending.

비공개 메소드들

메소드 설명
CreateEvent ( ) : ErrorEventArgs

메소드 상세

Add() 공개 메소드

Adds a critical, unexpected error.
public Add ( Exception ex, string comment ) : void
ex System.Exception The unexpected exception. Must not be null.
comment string Comment associated to the error (such as the name of the culprit). Can be null.
리턴 void

Clear() 공개 메소드

Clears the list. Only errors that have been already raised by OnErrorFromBackgroundThreads are removed from the internal buffer: it can be safely called at any time.
public Clear ( ) : void
리턴 void

Clear() 공개 메소드

Clears the list. Only errors that have been already raised by OnErrorFromBackgroundThreads are removed from the internal buffer: it can be safely called at any time.
public Clear ( int &cleared, int &waitingToBeRaisedErrors ) : void
cleared int Number of suppressed errors.
waitingToBeRaisedErrors int The number of errors waiting to be raised.
리턴 void

CriticalErrorCollector() 공개 메소드

Initializes a new CriticalErrorCollector with a default Capacity set to 128.
public CriticalErrorCollector ( ) : System
리턴 System

DoRaiseInBackground() 공개 메소드

public DoRaiseInBackground ( object unusedState ) : void
unusedState object
리턴 void

ToArray() 공개 메소드

Obtains a copy of the last (up to) Capacity errors from oldest to newest. The newest may have not been raised by OnErrorFromBackgroundThreads yet.
public ToArray ( ) : Error[]
리턴 Error[]

WaitOnErrorFromBackgroundThreadsPending() 공개 메소드

Blocks the caller thread until no more event is waiting to be raised by OnErrorFromBackgroundThreads or is being processed. This is the right function to use instead of pooling OnErrorFromBackgroundThreadsPending.
public WaitOnErrorFromBackgroundThreadsPending ( ) : void
리턴 void