Class AsyncDelegate
Provides set of methods for asynchronous invocation of various delegates.
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
public static class AsyncDelegate : object
Remarks
In .NET Core, BeginInvoke and EndInvoke methods of delegate type are not supported. This class provides alternative approach which allows to invoke delegate asynchronously with full support of async/await feature.
Methods
| Improve this Doc View SourceInvokeAsync(Action, CancellationToken)
Invokes action asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync(this Action action, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
Action | action | The action to invoke asynchronously. |
CancellationToken | token | Invocation cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | The task representing state of asynchronous invocation. |
InvokeAsync(EventHandler, Object, EventArgs, CancellationToken)
Invokes event handlers asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync(this EventHandler handler, object sender, EventArgs args, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
EventHandler | handler | A set event handlers combined as single delegate. |
Object | sender | Event sender. |
EventArgs | args | Event arguments. |
CancellationToken | token | Optional cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | An object representing state of the asynchronous invocation. |
InvokeAsync<D>(D, Action<D>, CancellationToken)
Invokes a delegate of arbitrary type asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync<D>(this D delegate, Action<D> invoker, CancellationToken token = null)
where D : MulticastDelegate
Parameters
Type | Name | Description |
---|---|---|
D | delegate | A delegate to be invoked asynchronously. |
Action<D> | invoker | Synchronous invoker of the delegate from invocation list. |
CancellationToken | token | Cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | A task allows to control asynchronous invocation of methods attached to the multicast delegate. |
Type Parameters
Name | Description |
---|---|
D | Type of delegate to invoke. |
InvokeAsync<T>(Action<T>, T, CancellationToken)
Invokes action asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync<T>(this Action<T> action, T arg, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
Action<T> | action | The action to invoke asynchronously. |
T | arg | The action argument. |
CancellationToken | token | Invocation cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | The task representing state of asynchronous invocation. |
Type Parameters
Name | Description |
---|---|
T | Type of the action argument. |
InvokeAsync<E>(EventHandler<E>, Object, E, CancellationToken)
Invokes event handlers asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync<E>(this EventHandler<E> handler, object sender, E args, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
EventHandler<E> | handler | A set event handlers combined as single delegate. |
Object | sender | Event sender. |
E | args | Event arguments. |
CancellationToken | token | Optional cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | An object representing state of the asynchronous invocation. |
Type Parameters
Name | Description |
---|---|
E | Type of event object. |
InvokeAsync<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, CancellationToken)
Invokes action asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
Action<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> | action | The action to invoke asynchronously. |
T1 | arg1 | The first action argument. |
T2 | arg2 | The second action argument. |
T3 | arg3 | The third action argument. |
T4 | arg4 | The fourth action argument. |
T5 | arg5 | The fifth action argument. |
T6 | arg6 | The sixth action argument. |
T7 | arg7 | The seventh action argument. |
T8 | arg8 | The eighth action argument. |
T9 | arg9 | The ninth action argument. |
T10 | arg10 | The tenth action argument. |
CancellationToken | token | Invocation cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | The task representing state of asynchronous invocation. |
Type Parameters
Name | Description |
---|---|
T1 | Type of the first action argument. |
T2 | Type of the second action argument. |
T3 | Type of the third action argument. |
T4 | Type of the fourth action argument. |
T5 | Type of the fifth action argument. |
T6 | Type of the sixth action argument. |
T7 | Type of the seventh action argument. |
T8 | Type of the eighth action argument. |
T9 | Type of the ninth action argument. |
T10 | Type of the tenth action argument. |
InvokeAsync<T1, T2>(Action<T1, T2>, T1, T2, CancellationToken)
Invokes action asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync<T1, T2>(this Action<T1, T2> action, T1 arg1, T2 arg2, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
Action<T1, T2> | action | The action to invoke asynchronously. |
T1 | arg1 | The first action argument. |
T2 | arg2 | The second action argument. |
CancellationToken | token | Invocation cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | The task representing state of asynchronous invocation. |
Type Parameters
Name | Description |
---|---|
T1 | Type of the first action argument. |
T2 | Type of the second action argument. |
InvokeAsync<T1, T2, T3>(Action<T1, T2, T3>, T1, T2, T3, CancellationToken)
Invokes action asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync<T1, T2, T3>(this Action<T1, T2, T3> action, T1 arg1, T2 arg2, T3 arg3, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
Action<T1, T2, T3> | action | The action to invoke asynchronously. |
T1 | arg1 | The first action argument. |
T2 | arg2 | The second action argument. |
T3 | arg3 | The third action argument. |
CancellationToken | token | Invocation cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | The task representing state of asynchronous invocation. |
Type Parameters
Name | Description |
---|---|
T1 | Type of the first action argument. |
T2 | Type of the second action argument. |
T3 | Type of the third action argument. |
InvokeAsync<T1, T2, T3, T4>(Action<T1, T2, T3, T4>, T1, T2, T3, T4, CancellationToken)
Invokes action asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync<T1, T2, T3, T4>(this Action<T1, T2, T3, T4> action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
Action<T1, T2, T3, T4> | action | The action to invoke asynchronously. |
T1 | arg1 | The first action argument. |
T2 | arg2 | The second action argument. |
T3 | arg3 | The third action argument. |
T4 | arg4 | The fourth action argument. |
CancellationToken | token | Invocation cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | The task representing state of asynchronous invocation. |
Type Parameters
Name | Description |
---|---|
T1 | Type of the first action argument. |
T2 | Type of the second action argument. |
T3 | Type of the third action argument. |
T4 | Type of the fourth action argument. |
InvokeAsync<T1, T2, T3, T4, T5>(Action<T1, T2, T3, T4, T5>, T1, T2, T3, T4, T5, CancellationToken)
Invokes action asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync<T1, T2, T3, T4, T5>(this Action<T1, T2, T3, T4, T5> action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
Action<T1, T2, T3, T4, T5> | action | The action to invoke asynchronously. |
T1 | arg1 | The first action argument. |
T2 | arg2 | The second action argument. |
T3 | arg3 | The third action argument. |
T4 | arg4 | The fourth action argument. |
T5 | arg5 | The fifth action argument. |
CancellationToken | token | Invocation cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | The task representing state of asynchronous invocation. |
Type Parameters
Name | Description |
---|---|
T1 | Type of the first action argument. |
T2 | Type of the second action argument. |
T3 | Type of the third action argument. |
T4 | Type of the fourth action argument. |
T5 | Type of the fifth action argument. |
InvokeAsync<T1, T2, T3, T4, T5, T6>(Action<T1, T2, T3, T4, T5, T6>, T1, T2, T3, T4, T5, T6, CancellationToken)
Invokes action asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync<T1, T2, T3, T4, T5, T6>(this Action<T1, T2, T3, T4, T5, T6> action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
Action<T1, T2, T3, T4, T5, T6> | action | The action to invoke asynchronously. |
T1 | arg1 | The first action argument. |
T2 | arg2 | The second action argument. |
T3 | arg3 | The third action argument. |
T4 | arg4 | The fourth action argument. |
T5 | arg5 | The fifth action argument. |
T6 | arg6 | The sixth action argument. |
CancellationToken | token | Invocation cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | The task representing state of asynchronous invocation. |
Type Parameters
Name | Description |
---|---|
T1 | Type of the first action argument. |
T2 | Type of the second action argument. |
T3 | Type of the third action argument. |
T4 | Type of the fourth action argument. |
T5 | Type of the fifth action argument. |
T6 | Type of the sixth action argument. |
InvokeAsync<T1, T2, T3, T4, T5, T6, T7>(Action<T1, T2, T3, T4, T5, T6, T7>, T1, T2, T3, T4, T5, T6, T7, CancellationToken)
Invokes action asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync<T1, T2, T3, T4, T5, T6, T7>(this Action<T1, T2, T3, T4, T5, T6, T7> action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
Action<T1, T2, T3, T4, T5, T6, T7> | action | The action to invoke asynchronously. |
T1 | arg1 | The first action argument. |
T2 | arg2 | The second action argument. |
T3 | arg3 | The third action argument. |
T4 | arg4 | The fourth action argument. |
T5 | arg5 | The fifth action argument. |
T6 | arg6 | The sixth action argument. |
T7 | arg7 | The seventh action argument. |
CancellationToken | token | Invocation cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | The task representing state of asynchronous invocation. |
Type Parameters
Name | Description |
---|---|
T1 | Type of the first action argument. |
T2 | Type of the second action argument. |
T3 | Type of the third action argument. |
T4 | Type of the fourth action argument. |
T5 | Type of the fifth action argument. |
T6 | Type of the sixth action argument. |
T7 | Type of the seventh action argument. |
InvokeAsync<T1, T2, T3, T4, T5, T6, T7, T8>(Action<T1, T2, T3, T4, T5, T6, T7, T8>, T1, T2, T3, T4, T5, T6, T7, T8, CancellationToken)
Invokes action asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync<T1, T2, T3, T4, T5, T6, T7, T8>(this Action<T1, T2, T3, T4, T5, T6, T7, T8> action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
Action<T1, T2, T3, T4, T5, T6, T7, T8> | action | The action to invoke asynchronously. |
T1 | arg1 | The first action argument. |
T2 | arg2 | The second action argument. |
T3 | arg3 | The third action argument. |
T4 | arg4 | The fourth action argument. |
T5 | arg5 | The fifth action argument. |
T6 | arg6 | The sixth action argument. |
T7 | arg7 | The seventh action argument. |
T8 | arg8 | The eighth action argument. |
CancellationToken | token | Invocation cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | The task representing state of asynchronous invocation. |
Type Parameters
Name | Description |
---|---|
T1 | Type of the first action argument. |
T2 | Type of the second action argument. |
T3 | Type of the third action argument. |
T4 | Type of the fourth action argument. |
T5 | Type of the fifth action argument. |
T6 | Type of the sixth action argument. |
T7 | Type of the seventh action argument. |
T8 | Type of the eighth action argument. |
InvokeAsync<T1, T2, T3, T4, T5, T6, T7, T8, T9>(Action<T1, T2, T3, T4, T5, T6, T7, T8, T9>, T1, T2, T3, T4, T5, T6, T7, T8, T9, CancellationToken)
Invokes action asynchronously.
Declaration
public static AsyncDelegateFuture InvokeAsync<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this Action<T1, T2, T3, T4, T5, T6, T7, T8, T9> action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, CancellationToken token = null)
Parameters
Type | Name | Description |
---|---|---|
Action<T1, T2, T3, T4, T5, T6, T7, T8, T9> | action | The action to invoke asynchronously. |
T1 | arg1 | The first action argument. |
T2 | arg2 | The second action argument. |
T3 | arg3 | The third action argument. |
T4 | arg4 | The fourth action argument. |
T5 | arg5 | The fifth action argument. |
T6 | arg6 | The sixth action argument. |
T7 | arg7 | The seventh action argument. |
T8 | arg8 | The eighth action argument. |
T9 | arg9 | THe ninth action argument. |
CancellationToken | token | Invocation cancellation token. |
Returns
Type | Description |
---|---|
AsyncDelegateFuture | The task representing state of asynchronous invocation. |
Type Parameters
Name | Description |
---|---|
T1 | Type of the first action argument. |
T2 | Type of the second action argument. |
T3 | Type of the third action argument. |
T4 | Type of the fourth action argument. |
T5 | Type of the fifth action argument. |
T6 | Type of the sixth action argument. |
T7 | Type of the seventh action argument. |
T8 | Type of the eighth action argument. |
T9 | Type of the ninth action argument. |