Compartir a través de


TplExtensions.InvokeAsync<TEventArgs> Method (AsyncEventHandler<TEventArgs>, Object, TEventArgs)

Invokes asynchronous event handlers, returning a task that completes when all event handlers have been invoked. Each handler is fully executed (including continuations) before the next handler in the list is invoked.

Namespace:  Microsoft.VisualStudio.Threading
Assembly:  Microsoft.VisualStudio.Threading (in Microsoft.VisualStudio.Threading.dll)

Syntax

'Declaration
<ExtensionAttribute> _
Public Shared Function InvokeAsync(Of TEventArgs As EventArgs) ( _
    handlers As AsyncEventHandler(Of TEventArgs), _
    sender As Object, _
    args As TEventArgs _
) As Task
public static Task InvokeAsync<TEventArgs>(
    this AsyncEventHandler<TEventArgs> handlers,
    Object sender,
    TEventArgs args
)
where TEventArgs : EventArgs
[ExtensionAttribute]
public:
generic<typename TEventArgs>
where TEventArgs : EventArgs 
static Task^ InvokeAsync(
    AsyncEventHandler<TEventArgs>^ handlers, 
    Object^ sender, 
    TEventArgs args
)
static member InvokeAsync : 
        handlers:AsyncEventHandler<'TEventArgs> * 
        sender:Object * 
        args:'TEventArgs -> Task   when 'TEventArgs : EventArgs
JScript does not support generic types or methods.

Type Parameters

  • TEventArgs

Parameters

  • args
    Type: TEventArgs

    The event argument.

Return Value

Type: System.Threading.Tasks.Task
A Task that completes when all handlers have completed. The task is faulted if any handlers throw an exception.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type AsyncEventHandler<TEventArgs>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

Exception Condition
AggregateException

Thrown if any handlers fail. It contains a collection of all failures.

.NET Framework Security

See Also

Reference

TplExtensions Class

InvokeAsync Overload

Microsoft.VisualStudio.Threading Namespace