This documentation is archived and is not being maintained.

Asynchronous Delegates

Asynchronous delegates provide the ability to call a synchronous method in an asynchronous manner. When you call a delegate synchronously, the Invoke method calls the target method directly on the current thread. If the compiler supports asynchronous delegates, then it will generate the Invoke method and the BeginInvoke and EndInvoke methods. If the BeginInvoke method is called, the common language runtime will queue the request and return immediately to the caller. The target method will be called on a thread from the thread pool. The original thread, which submitted the request, is free to continue executing in parallel to the target method, which is running on a thread pool thread. If a callback has been specified on the BeginInvoke, it will be called when the target method returns. In the callback, the EndInvoke method is used to obtain the return value and the in/out parameters. If the callback was not specified on the BeginInvoke, then EndInvoke can be used on the original thread that submitted a request.

Note   The Microsoft C# compiler currently supports an asynchronous delegate.

In This Section

Using Delegates
Describes how to implement asynchronous delegates programmatically.
Compiler and Common Language Runtime Support
Explains compiler support for the runtime, using BeginInvoke and EndInvoke with asynchronous method signatures.
Compiler-Supplied Delegate BeginInvoke and EndInvoke Methods
Discusses compiler-specific issues with BeginInvoke and EndInvoke methods.
Asynchronous Delegates Programming Sample
Demonstrates the use of asynchronous delegates in a simple sample, which factorizes some numbers.

Related Sections

Asynchronous Programming
Describes orientation for asynchronous programming with the .NET Framework.