Breyta

Deila með


Dispatcher.InvokeAsync Method

Definition

Executes the specified delegate asynchronously on the thread the Dispatcher is associated with.

Overloads

InvokeAsync(Action)

Executes the specified Action asynchronously on the thread the Dispatcher is associated with.

InvokeAsync(Action, DispatcherPriority)

Executes the specified Action asynchronously at the specified priority on the thread the Dispatcher is associated with.

InvokeAsync(Action, DispatcherPriority, CancellationToken)

Executes the specified Action asynchronously at the specified priority on the thread the Dispatcher is associated with.

InvokeAsync<TResult>(Func<TResult>, DispatcherPriority, CancellationToken)

Executes the specified Func<TResult> asynchronously at the specified priority on the thread the Dispatcher is associated with.

InvokeAsync<TResult>(Func<TResult>)

Executes the specified Func<TResult> asynchronously on the thread the Dispatcher is associated with.

InvokeAsync<TResult>(Func<TResult>, DispatcherPriority)

Executes the specified Func<TResult> asynchronously at the specified priority on the thread the Dispatcher is associated with.

InvokeAsync(Action)

Executes the specified Action asynchronously on the thread the Dispatcher is associated with.

public:
 System::Windows::Threading::DispatcherOperation ^ InvokeAsync(Action ^ callback);
public System.Windows.Threading.DispatcherOperation InvokeAsync (Action callback);
member this.InvokeAsync : Action -> System.Windows.Threading.DispatcherOperation
Public Function InvokeAsync (callback As Action) As DispatcherOperation

Parameters

callback
Action

A delegate to invoke through the dispatcher.

Returns

An object, which is returned immediately after InvokeAsync(Action) is called, that can be used to interact with the delegate as it is pending execution in the event queue.

Remarks

The default priority is DispatcherPriority.Normal.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Invoke(Action).

Applies to

InvokeAsync(Action, DispatcherPriority)

Executes the specified Action asynchronously at the specified priority on the thread the Dispatcher is associated with.

public:
 System::Windows::Threading::DispatcherOperation ^ InvokeAsync(Action ^ callback, System::Windows::Threading::DispatcherPriority priority);
public System.Windows.Threading.DispatcherOperation InvokeAsync (Action callback, System.Windows.Threading.DispatcherPriority priority);
member this.InvokeAsync : Action * System.Windows.Threading.DispatcherPriority -> System.Windows.Threading.DispatcherOperation
Public Function InvokeAsync (callback As Action, priority As DispatcherPriority) As DispatcherOperation

Parameters

callback
Action

A delegate to invoke through the dispatcher.

priority
DispatcherPriority

The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.

Returns

An object, which is returned immediately after InvokeAsync(Action, DispatcherPriority) is called, that can be used to interact with the delegate as it is pending execution in the event queue.

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Invoke(Action, DispatcherPriority).

Applies to

InvokeAsync(Action, DispatcherPriority, CancellationToken)

Executes the specified Action asynchronously at the specified priority on the thread the Dispatcher is associated with.

public:
 System::Windows::Threading::DispatcherOperation ^ InvokeAsync(Action ^ callback, System::Windows::Threading::DispatcherPriority priority, System::Threading::CancellationToken cancellationToken);
public System.Windows.Threading.DispatcherOperation InvokeAsync (Action callback, System.Windows.Threading.DispatcherPriority priority, System.Threading.CancellationToken cancellationToken);
member this.InvokeAsync : Action * System.Windows.Threading.DispatcherPriority * System.Threading.CancellationToken -> System.Windows.Threading.DispatcherOperation
Public Function InvokeAsync (callback As Action, priority As DispatcherPriority, cancellationToken As CancellationToken) As DispatcherOperation

Parameters

callback
Action

A delegate to invoke through the dispatcher.

priority
DispatcherPriority

The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.

cancellationToken
CancellationToken

An object that indicates whether to cancel the action.

Returns

An object, which is returned immediately after InvokeAsync(Action, DispatcherPriority, CancellationToken) is called, that can be used to interact with the delegate as it is pending execution in the event queue.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Invoke(Action, DispatcherPriority).

Applies to

InvokeAsync<TResult>(Func<TResult>, DispatcherPriority, CancellationToken)

Executes the specified Func<TResult> asynchronously at the specified priority on the thread the Dispatcher is associated with.

public:
generic <typename TResult>
 System::Windows::Threading::DispatcherOperation<TResult> ^ InvokeAsync(Func<TResult> ^ callback, System::Windows::Threading::DispatcherPriority priority, System::Threading::CancellationToken cancellationToken);
public System.Windows.Threading.DispatcherOperation<TResult> InvokeAsync<TResult> (Func<TResult> callback, System.Windows.Threading.DispatcherPriority priority, System.Threading.CancellationToken cancellationToken);
member this.InvokeAsync : Func<'Result> * System.Windows.Threading.DispatcherPriority * System.Threading.CancellationToken -> System.Windows.Threading.DispatcherOperation<'Result>
Public Function InvokeAsync(Of TResult) (callback As Func(Of TResult), priority As DispatcherPriority, cancellationToken As CancellationToken) As DispatcherOperation(Of TResult)

Type Parameters

TResult

The return value type of the specified delegate.

Parameters

callback
Func<TResult>

A delegate to invoke through the dispatcher.

priority
DispatcherPriority

The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.

cancellationToken
CancellationToken

An object that indicates whether to cancel the operation.

Returns

An object, which is returned immediately after InvokeAsync<TResult>(Func<TResult>, DispatcherPriority, CancellationToken) is called, that can be used to interact with the delegate as it is pending execution in the event queue.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Applies to

InvokeAsync<TResult>(Func<TResult>)

Executes the specified Func<TResult> asynchronously on the thread the Dispatcher is associated with.

public:
generic <typename TResult>
 System::Windows::Threading::DispatcherOperation<TResult> ^ InvokeAsync(Func<TResult> ^ callback);
public System.Windows.Threading.DispatcherOperation<TResult> InvokeAsync<TResult> (Func<TResult> callback);
member this.InvokeAsync : Func<'Result> -> System.Windows.Threading.DispatcherOperation<'Result>
Public Function InvokeAsync(Of TResult) (callback As Func(Of TResult)) As DispatcherOperation(Of TResult)

Type Parameters

TResult

The return value type of the specified delegate.

Parameters

callback
Func<TResult>

A delegate to invoke through the dispatcher.

Returns

An object, which is returned immediately after InvokeAsync<TResult>(Func<TResult>) is called, that can be used to interact with the delegate as it is pending execution in the event queue.

Applies to

InvokeAsync<TResult>(Func<TResult>, DispatcherPriority)

Executes the specified Func<TResult> asynchronously at the specified priority on the thread the Dispatcher is associated with.

public:
generic <typename TResult>
 System::Windows::Threading::DispatcherOperation<TResult> ^ InvokeAsync(Func<TResult> ^ callback, System::Windows::Threading::DispatcherPriority priority);
public System.Windows.Threading.DispatcherOperation<TResult> InvokeAsync<TResult> (Func<TResult> callback, System.Windows.Threading.DispatcherPriority priority);
member this.InvokeAsync : Func<'Result> * System.Windows.Threading.DispatcherPriority -> System.Windows.Threading.DispatcherOperation<'Result>
Public Function InvokeAsync(Of TResult) (callback As Func(Of TResult), priority As DispatcherPriority) As DispatcherOperation(Of TResult)

Type Parameters

TResult

The return value type of the specified delegate.

Parameters

callback
Func<TResult>

A delegate to invoke through the dispatcher.

priority
DispatcherPriority

The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.

Returns

An object, which is returned immediately after InvokeAsync<TResult>(Func<TResult>, DispatcherPriority) is called, that can be used to interact with the delegate as it is pending execution in the event queue.

Applies to