Bagikan melalui


TplExtensions.InvokeAsync Method (AsyncEventHandler, Object, EventArgs)

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 ( _
    handlers As AsyncEventHandler, _
    sender As Object, _
    args As EventArgs _
) As Task
public static Task InvokeAsync(
    this AsyncEventHandler handlers,
    Object sender,
    EventArgs args
)
[ExtensionAttribute]
public:
static Task^ InvokeAsync(
    AsyncEventHandler^ handlers, 
    Object^ sender, 
    EventArgs^ args
)
static member InvokeAsync : 
        handlers:AsyncEventHandler * 
        sender:Object * 
        args:EventArgs -> Task
public static function InvokeAsync(
    handlers : AsyncEventHandler, 
    sender : Object, 
    args : EventArgs
) : Task

Parameters

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. 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