C# Class Sanford.Threading.DelegateQueue

Represents an asynchronous queue of delegates.
Inheritance: System.Threading.SynchronizationContext, IComponent, ISynchronizeInvoke
Datei anzeigen Open project: hmadrigal/playground-dotnet Class Usage Examples

Public Methods

Method Description
BeginInvoke ( Delegate method ) : IAsyncResult

Executes the delegate on the main thread that this DelegateQueue executes on.

The delegate is called asynchronously, and this method returns immediately. You can call this method from any thread. If you need the return value from a process started with this method, call EndInvoke to get the value.

If you need to call the delegate synchronously, use the Invoke method instead.

DelegateQueue ( string name ) : System

Initializes a new instance of the DelegateQueue class.

DelegateQueue ( string name, IContainer container ) : System

Initializes a new instance of the DelegateQueue class with the specified IContainer object.

Dispose ( ) : void

Disposes of the DelegateQueue.

EndInvoke ( IAsyncResult result ) : object

Waits until the process started by calling BeginInvoke completes, and then returns the value generated by the process.

This method gets the return value of the asynchronous operation represented by the IAsyncResult passed by this interface. If the asynchronous operation has not completed, this method will wait until the result is available.

Invoke ( Delegate method ) : object

Executes the delegate on the main thread that this DelegateQueue executes on.

Unlike BeginInvoke, this method operates synchronously, that is, it waits until the process completes before returning. Exceptions raised during the call are propagated back to the caller.

Use this method when calling a method from a different thread to marshal the call to the proper thread.

Post ( SendOrPostCallback d, object state ) : void

Dispatches an asynchronous message to this synchronization context.

The Post method starts an asynchronous request to post a message.

Send ( SendOrPostCallback d, object state ) : void

Dispatches a synchronous message to this synchronization context.

The Send method starts an synchronous request to send a message.

Protected Methods

Method Description
Dispose ( bool disposing ) : void
OnDisposed ( EventArgs e ) : void
OnInvokeCompleted ( InvokeCompletedEventArgs e ) : void
OnPostCompleted ( Sanford.Threading.PostCompletedEventArgs e ) : void

Private Methods

Method Description
DelegateProcedure ( ) : void
InitializeDelegateQueue ( string name ) : void

Method Details

BeginInvoke() public method

Executes the delegate on the main thread that this DelegateQueue executes on.

The delegate is called asynchronously, and this method returns immediately. You can call this method from any thread. If you need the return value from a process started with this method, call EndInvoke to get the value.

If you need to call the delegate synchronously, use the Invoke method instead.

public BeginInvoke ( Delegate method ) : IAsyncResult
method System.Delegate /// A Delegate to a method that takes parameters of the same number and type that /// are contained in args. ///
return IAsyncResult

DelegateQueue() public method

Initializes a new instance of the DelegateQueue class.
public DelegateQueue ( string name ) : System
name string
return System

DelegateQueue() public method

Initializes a new instance of the DelegateQueue class with the specified IContainer object.
public DelegateQueue ( string name, IContainer container ) : System
name string
container IContainer /// The IContainer to which the DelegateQueue will add itself. ///
return System

Dispose() public method

Disposes of the DelegateQueue.
public Dispose ( ) : void
return void

Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void

EndInvoke() public method

Waits until the process started by calling BeginInvoke completes, and then returns the value generated by the process.
This method gets the return value of the asynchronous operation represented by the IAsyncResult passed by this interface. If the asynchronous operation has not completed, this method will wait until the result is available.
public EndInvoke ( IAsyncResult result ) : object
result IAsyncResult /// An IAsyncResult interface that represents the asynchronous operation started /// by calling BeginInvoke. ///
return object

Invoke() public method

Executes the delegate on the main thread that this DelegateQueue executes on.

Unlike BeginInvoke, this method operates synchronously, that is, it waits until the process completes before returning. Exceptions raised during the call are propagated back to the caller.

Use this method when calling a method from a different thread to marshal the call to the proper thread.

public Invoke ( Delegate method ) : object
method System.Delegate /// A Delegate that contains a method to call, in the context of the thread for the DelegateQueue. ///
return object

OnDisposed() protected method

protected OnDisposed ( EventArgs e ) : void
e System.EventArgs
return void

OnInvokeCompleted() protected method

protected OnInvokeCompleted ( InvokeCompletedEventArgs e ) : void
e InvokeCompletedEventArgs
return void

OnPostCompleted() protected method

protected OnPostCompleted ( Sanford.Threading.PostCompletedEventArgs e ) : void
e Sanford.Threading.PostCompletedEventArgs
return void

Post() public method

Dispatches an asynchronous message to this synchronization context.
The Post method starts an asynchronous request to post a message.
public Post ( SendOrPostCallback d, object state ) : void
d SendOrPostCallback /// The SendOrPostCallback delegate to call. ///
state object /// The object passed to the delegate. ///
return void

Send() public method

Dispatches a synchronous message to this synchronization context.
The Send method starts an synchronous request to send a message.
public Send ( SendOrPostCallback d, object state ) : void
d SendOrPostCallback /// The SendOrPostCallback delegate to call. ///
state object /// The object passed to the delegate. ///
return void