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
handlers
Type: Microsoft.VisualStudio.Threading.AsyncEventHandler<TEventArgs>The event handlers. May be nulla null reference (Nothing in Visual Basic).
sender
Type: System.ObjectThe event source.
args
Type: TEventArgsThe 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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.