C# 클래스 ANHAdmin.AsyncOperation

This base class is designed to be used by lengthy operations that wish to support cancellation. It also allows those operations to invoke delegates on the UI Thread of a hosting control.
This class is from the MSDN article: http://msdn.microsoft.com/msdnmag/issues/03/02/Multithreading/default.aspx (C) 2001-2002 I D Griffiths Please see the article for a complete description of the intentions and operation of this class.
파일 보기 프로젝트 열기: swganhtools/anhserverconfigurationtool

공개 메소드들

메소드 설명
AsyncOperation ( ISynchronizeInvoke target ) : System

Initialises an AsyncOperation with an association to the supplied ISynchronizeInvoke. All events raised from this object will be delivered via this target. (This might be a Control object, so events would be delivered to that Control's UI thread.)

Cancel ( ) : void

Attempt to cancel the current operation. This returns immediately to the caller. No guarantee is made as to whether the operation will be successfully cancelled. All that can be known is that at some point, one of the three events Completed, Cancelled, or Failed will be raised at some point.

CancelAndWait ( ) : bool

Attempt to cancel the current operation and block until either the cancellation succeeds or the operation completes.

Start ( ) : void

Launch the operation on a worker thread. This method will return immediately, and the operation will start asynchronously on a worker thread.

WaitUntilDone ( ) : bool

Blocks until the operation has either run to completion, or has been successfully cancelled, or has failed with an internal exception.

보호된 메소드들

메소드 설명
AcknowledgeCancel ( ) : void

This is called by the operation when it wants to indicate that it saw the cancellation request and honoured it.

DoWork ( ) : void

To be overridden by the deriving class - this is where the work will be done. The base class calls this method on a worker thread when the Start method is called.

FireAsync ( Delegate dlg ) : void

Utility function for firing an event through the target. It uses C#'s variable length parameter list support to build the parameter list. This functions presumes that the caller holds the object lock. (This is because the event list is typically modified on the UI thread, but events are usually raised on the worker thread.)

비공개 메소드들

메소드 설명
CompleteOperation ( ) : void
FailOperation ( Exception e ) : void

InternalStart ( ) : void

메소드 상세

AcknowledgeCancel() 보호된 메소드

This is called by the operation when it wants to indicate that it saw the cancellation request and honoured it.
protected AcknowledgeCancel ( ) : void
리턴 void

AsyncOperation() 공개 메소드

Initialises an AsyncOperation with an association to the supplied ISynchronizeInvoke. All events raised from this object will be delivered via this target. (This might be a Control object, so events would be delivered to that Control's UI thread.)
public AsyncOperation ( ISynchronizeInvoke target ) : System
target ISynchronizeInvoke An object implementing the /// ISynchronizeInvoke interface. All events will be delivered /// through this target, ensuring that they are delivered to the /// correct thread.
리턴 System

Cancel() 공개 메소드

Attempt to cancel the current operation. This returns immediately to the caller. No guarantee is made as to whether the operation will be successfully cancelled. All that can be known is that at some point, one of the three events Completed, Cancelled, or Failed will be raised at some point.
public Cancel ( ) : void
리턴 void

CancelAndWait() 공개 메소드

Attempt to cancel the current operation and block until either the cancellation succeeds or the operation completes.
public CancelAndWait ( ) : bool
리턴 bool

DoWork() 보호된 추상적인 메소드

To be overridden by the deriving class - this is where the work will be done. The base class calls this method on a worker thread when the Start method is called.
protected abstract DoWork ( ) : void
리턴 void

FireAsync() 보호된 메소드

Utility function for firing an event through the target. It uses C#'s variable length parameter list support to build the parameter list. This functions presumes that the caller holds the object lock. (This is because the event list is typically modified on the UI thread, but events are usually raised on the worker thread.)
protected FireAsync ( Delegate dlg ) : void
dlg System.Delegate
리턴 void

Start() 공개 메소드

Launch the operation on a worker thread. This method will return immediately, and the operation will start asynchronously on a worker thread.
public Start ( ) : void
리턴 void

WaitUntilDone() 공개 메소드

Blocks until the operation has either run to completion, or has been successfully cancelled, or has failed with an internal exception.
public WaitUntilDone ( ) : bool
리턴 bool