Dispatcher.InvokeAsync 方法

定义

在与之关联的线程 Dispatcher 上异步执行指定的委托。

重载

名称 说明
InvokeAsync(Action)

在与之关联的线程Action上异步执行指定的Dispatcher操作。

InvokeAsync(Action, DispatcherPriority)

Action在与之关联的线程Dispatcher上以指定优先级异步执行指定。

InvokeAsync(Action, DispatcherPriority, CancellationToken)

Action在与之关联的线程Dispatcher上以指定优先级异步执行指定。

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

Func<TResult>在与之关联的线程Dispatcher上以指定优先级异步执行指定。

InvokeAsync<TResult>(Func<TResult>)

在与之关联的线程Func<TResult>上异步执行指定的Dispatcher操作。

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

Func<TResult>在与之关联的线程Dispatcher上以指定优先级异步执行指定。

InvokeAsync(Action)

在与之关联的线程Action上异步执行指定的Dispatcher操作。

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

参数

callback
Action

要通过调度程序调用的委托。

返回

调用后 InvokeAsync(Action) 立即返回的对象,该对象可用于在事件队列中等待执行时与委托进行交互。

注解

默认优先级为 DispatcherPriority.Normal.

此方法存储在任务中,它返回该方法的同步对应项可以引发的所有非使用异常。 如果异常存储在返回的任务中,则等待任务时将引发该异常。 使用情况异常(例如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅由 Invoke(Action)..

适用于

InvokeAsync(Action, DispatcherPriority)

Action在与之关联的线程Dispatcher上以指定优先级异步执行指定。

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

参数

callback
Action

要通过调度程序调用的委托。

priority
DispatcherPriority

确定指定回调相对于中其他挂起操作的调用顺序的 Dispatcher优先级。

返回

调用后 InvokeAsync(Action, DispatcherPriority) 立即返回的对象,该对象可用于在事件队列中等待执行时与委托进行交互。

注解

此方法存储在任务中,它返回该方法的同步对应项可以引发的所有非使用异常。 如果异常存储在返回的任务中,则等待任务时将引发该异常。 使用情况异常(例如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅由 Invoke(Action, DispatcherPriority)..

适用于

InvokeAsync(Action, DispatcherPriority, CancellationToken)

Action在与之关联的线程Dispatcher上以指定优先级异步执行指定。

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

参数

callback
Action

要通过调度程序调用的委托。

priority
DispatcherPriority

确定指定回调相对于中其他挂起操作的调用顺序的 Dispatcher优先级。

cancellationToken
CancellationToken

一个对象,指示是否取消操作。

返回

调用后 InvokeAsync(Action, DispatcherPriority, CancellationToken) 立即返回的对象,该对象可用于在事件队列中等待执行时与委托进行交互。

例外

取消令牌已取消。 此异常存储在返回的任务中。

注解

此方法存储在任务中,它返回该方法的同步对应项可以引发的所有非使用异常。 如果异常存储在返回的任务中,则等待任务时将引发该异常。 使用情况异常(例如 ArgumentException)仍会同步引发。 有关存储的异常,请参阅由 Invoke(Action, DispatcherPriority)..

适用于

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

Func<TResult>在与之关联的线程Dispatcher上以指定优先级异步执行指定。

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)

类型参数

TResult

指定委托的返回值类型。

参数

callback
Func<TResult>

要通过调度程序调用的委托。

priority
DispatcherPriority

确定指定回调相对于中其他挂起操作的调用顺序的 Dispatcher优先级。

cancellationToken
CancellationToken

一个对象,指示是否取消操作。

返回

调用后 InvokeAsync<TResult>(Func<TResult>, DispatcherPriority, CancellationToken) 立即返回的对象,该对象可用于在事件队列中等待执行时与委托进行交互。

例外

取消令牌已取消。 此异常存储在返回的任务中。

适用于

InvokeAsync<TResult>(Func<TResult>)

在与之关联的线程Func<TResult>上异步执行指定的Dispatcher操作。

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)

类型参数

TResult

指定委托的返回值类型。

参数

callback
Func<TResult>

要通过调度程序调用的委托。

返回

调用后 InvokeAsync<TResult>(Func<TResult>) 立即返回的对象,该对象可用于在事件队列中等待执行时与委托进行交互。

适用于

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

Func<TResult>在与之关联的线程Dispatcher上以指定优先级异步执行指定。

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)

类型参数

TResult

指定委托的返回值类型。

参数

callback
Func<TResult>

要通过调度程序调用的委托。

priority
DispatcherPriority

确定指定回调相对于中其他挂起操作的调用顺序的 Dispatcher优先级。

返回

调用后 InvokeAsync<TResult>(Func<TResult>, DispatcherPriority) 立即返回的对象,该对象可用于在事件队列中等待执行时与委托进行交互。

适用于