Dispatcher.Invoke メソッド
定義
Dispatcher が関連付けられているスレッドで、指定したデリゲートを同期的に実行します。Executes the specified delegate synchronously on the thread the Dispatcher is associated with.
オーバーロード
Invoke(DispatcherPriority, TimeSpan, Delegate, Object, Object[]) |
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で同期的に実行します。Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with. |
Invoke(DispatcherPriority, TimeSpan, Delegate, Object) |
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で同期的に実行します。Executes the specified delegate at the specified priority with the specified argument synchronously on the thread the Dispatcher is associated with. |
Invoke(DispatcherPriority, Delegate, Object, Object[]) |
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で同期的に実行します。Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with. |
Invoke(Action, DispatcherPriority, CancellationToken, TimeSpan) |
Action が関連付けられているスレッドで、指定した Dispatcher を指定した優先順位で同期的に実行します。Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke(DispatcherPriority, TimeSpan, Delegate) |
Dispatcher が作成されたスレッドで、指定したタイムアウトの値を使用して、指定したデリゲートを指定した優先順位で同期的に実行します。Executes the specified delegate synchronously at the specified priority and with the specified time-out value on the thread the Dispatcher was created. |
Invoke(DispatcherPriority, Delegate, Object) |
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で同期的に実行します。Executes the specified delegate at the specified priority with the specified argument synchronously on the thread the Dispatcher is associated with. |
Invoke(Delegate, TimeSpan, DispatcherPriority, Object[]) |
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で、指定した期間内に同期的に実行します。Executes the specified delegate within the designated time span at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with. |
Invoke(Delegate, TimeSpan, Object[]) |
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で、指定した期間内に同期的に実行します。Executes the specified delegate within the designated time span at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with. |
Invoke(Action, DispatcherPriority, CancellationToken) |
Action が関連付けられているスレッドで、指定した Dispatcher を指定した優先順位で同期的に実行します。Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke(DispatcherPriority, Delegate) |
が関連付けられているスレッドで、指定したデリゲートを指定した優先順位で同期的に実行し Dispatcher ます。Executes the specified delegate synchronously at the specified priority on the thread that the Dispatcher is associated with. |
Invoke(Delegate, Object[]) |
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを同期的に実行します。Executes the specified delegate with the specified arguments synchronously on the thread the Dispatcher is associated with. |
Invoke(Action, DispatcherPriority) |
Action が関連付けられているスレッドで、指定した Dispatcher を指定した優先順位で同期的に実行します。Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke(Action) |
Action が関連付けられているスレッドで、指定した Dispatcher を同期的に実行します。Executes the specified Action synchronously on the thread the Dispatcher is associated with. |
Invoke(Delegate, DispatcherPriority, Object[]) |
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で同期的に実行します。Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with. |
Invoke<TResult>(Func<TResult>) |
Func<TResult> が関連付けられているスレッドで、指定した Dispatcher を同期的に実行します。Executes the specified Func<TResult> synchronously on the thread the Dispatcher is associated with. |
Invoke<TResult>(Func<TResult>, DispatcherPriority) |
Func<TResult> が関連付けられているスレッドで、指定した Dispatcher を指定した優先順位で同期的に実行します。Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke<TResult>(Func<TResult>, DispatcherPriority, CancellationToken) |
Func<TResult> が関連付けられているスレッドで、指定した Dispatcher を指定した優先順位で同期的に実行します。Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with. |
Invoke<TResult>(Func<TResult>, DispatcherPriority, CancellationToken, TimeSpan) |
Func<TResult> が関連付けられているスレッドで、指定した Dispatcher を指定した優先順位で同期的に実行します。Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with. |
例
次の例では、を使用して、にデリゲートをに配置し Dispatcher Normal Invoke ます。The following example places a delegate onto a Dispatcher at Normal using Invoke.
// Places the delegate onto the UI Thread's Dispatcher
private void timer_Elapsed(object sender, ElapsedEventArgs e)
{
// Place delegate on the Dispatcher.
this.Dispatcher.Invoke(DispatcherPriority.Normal,
new TimerDispatcherDelegate(TimerWorkItem));
}
' Places the delegate onto the UI Thread's Dispatcher
Private Sub timer_Elapsed(ByVal sender As Object, ByVal e As ElapsedEventArgs)
' Place delegate on the Dispatcher.
Me.Dispatcher.Invoke(DispatcherPriority.Normal, New TimerDispatcherDelegate(AddressOf TimerWorkItem))
End Sub
注釈
WPF では、を作成したスレッドだけ DispatcherObject がそのオブジェクトにアクセスできます。In WPF, only the thread that created a DispatcherObject may access that object. たとえば、メイン UI スレッドからスピンオフされたバックグラウンドスレッドは、 Button ui スレッドで作成されたの内容を更新できません。For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. バックグラウンドスレッドがの Content プロパティにアクセスするためには、 Button Dispatcher UI スレッドに関連付けられているに作業を委任する必要があります。In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. これは、またはを使用して行い Invoke BeginInvoke ます。This is accomplished by using either Invoke or BeginInvoke. Invoke は同期的であり、 BeginInvoke 非同期です。Invoke is synchronous and BeginInvoke is asynchronous. 操作は、指定したののイベントキューに追加され Dispatcher DispatcherPriority ます。The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke は同期操作です。そのため、コールバックが戻るまで、コントロールは呼び出し元のオブジェクトに戻りません。Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
Invoke(DispatcherPriority, TimeSpan, Delegate, Object, Object[])
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で同期的に実行します。Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(System::Windows::Threading::DispatcherPriority priority, TimeSpan timeout, Delegate ^ method, System::Object ^ arg, ... cli::array <System::Object ^> ^ args);
[System.ComponentModel.Browsable(false)]
public object Invoke (System.Windows.Threading.DispatcherPriority priority, TimeSpan timeout, Delegate method, object arg, params object[] args);
[<System.ComponentModel.Browsable(false)>]
member this.Invoke : System.Windows.Threading.DispatcherPriority * TimeSpan * Delegate * obj * obj[] -> obj
Public Function Invoke (priority As DispatcherPriority, timeout As TimeSpan, method As Delegate, arg As Object, ParamArray args As Object()) As Object
パラメーター
- priority
- DispatcherPriority
Dispatcher指定されたメソッドが呼び出される、イベントキュー内の他の保留中の操作を基準とする優先順位。The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- timeout
- TimeSpan
操作の開始を待機する最大時間。The maximum amount of time to wait for the operation to start. 操作が開始されると、このメソッドが戻る前に完了します。Once the operation has started, it will complete before this method returns. 無期限の待機を指定するには、値-1 を使用します。To specify an infinite wait, use a value of -1. 同じスレッド呼び出しでは、その他の負の値は-1 に変換され、その結果、待機時間が無制限になります。In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. スレッド間の呼び出しでは、他の負の値がをスロー ArgumentOutOfRangeException します。In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- method
- Delegate
複数の引数を受け取るメソッドへのデリゲート。このデリゲートは、Dispatcher イベント キューにプッシュされます。A delegate to a method that takes multiple arguments, which is pushed onto the Dispatcher event queue.
- arg
- Object
指定したメソッドに引数として渡すオブジェクト。An object to pass as an argument to the specified method.
- args
- Object[]
指定したメソッドに引数として渡すオブジェクトの配列。An array of objects to pass as arguments to the specified method.
戻り値
呼び出されているデリゲートからの戻り値。デリゲートに戻り値がない場合は null
。The return value from the delegate being invoked or null
if the delegate has no return value.
- 属性
例外
priority
は有効な DispatcherPriority ではありません。priority
is not a valid DispatcherPriority.
method
が null
です。method
is null
.
timeout
が-1 以外の負の数値です。このメソッドはスレッド間で呼び出されました。timeout
is a negative number other than -1, and this method was invoked across threads.
注釈
arg``null
引数が不要な場合は、を指定できます。arg
can be null
if an argument is not needed.
WPF では、を作成したスレッドだけ DispatcherObject がそのオブジェクトにアクセスできます。In WPF, only the thread that created a DispatcherObject may access that object. たとえば、メイン UI スレッドからスピンオフされたバックグラウンドスレッドは、 Button ui スレッドで作成されたの内容を更新できません。For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. バックグラウンドスレッドがの Content プロパティにアクセスするためには、 Button Dispatcher UI スレッドに関連付けられているに作業を委任する必要があります。In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. これは、またはを使用して行い Invoke BeginInvoke ます。This is accomplished by using either Invoke or BeginInvoke. Invoke は同期的であり、 BeginInvoke 非同期です。Invoke is synchronous and BeginInvoke is asynchronous. 操作は、指定したののイベントキューに追加され Dispatcher DispatcherPriority ます。The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke は同期操作です。そのため、コールバックが戻るまで、コントロールは呼び出し元のオブジェクトに戻りません。Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
適用対象
Invoke(DispatcherPriority, TimeSpan, Delegate, Object)
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で同期的に実行します。Executes the specified delegate at the specified priority with the specified argument synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(System::Windows::Threading::DispatcherPriority priority, TimeSpan timeout, Delegate ^ method, System::Object ^ arg);
[System.ComponentModel.Browsable(false)]
public object Invoke (System.Windows.Threading.DispatcherPriority priority, TimeSpan timeout, Delegate method, object arg);
[<System.ComponentModel.Browsable(false)>]
member this.Invoke : System.Windows.Threading.DispatcherPriority * TimeSpan * Delegate * obj -> obj
Public Function Invoke (priority As DispatcherPriority, timeout As TimeSpan, method As Delegate, arg As Object) As Object
パラメーター
- priority
- DispatcherPriority
Dispatcher指定されたメソッドが呼び出される、イベントキュー内の他の保留中の操作を基準とする優先順位。The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- timeout
- TimeSpan
操作の開始を待機する最大時間。The maximum amount of time to wait for the operation to start. 操作が開始されると、このメソッドが戻る前に完了します。Once the operation has started, it will complete before this method returns. 無期限の待機を指定するには、値-1 を使用します。To specify an infinite wait, use a value of -1. 同じスレッド呼び出しでは、その他の負の値は-1 に変換され、その結果、待機時間が無制限になります。In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. スレッド間の呼び出しでは、他の負の値がをスロー ArgumentOutOfRangeException します。In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- method
- Delegate
複数の引数を受け取るメソッドへのデリゲート。このデリゲートは、Dispatcher イベント キューにプッシュされます。A delegate to a method that takes multiple arguments, which is pushed onto the Dispatcher event queue.
- arg
- Object
指定したメソッドに引数として渡すオブジェクト。An object to pass as an argument to the given method. 引数が必要ない場合は、null
を指定できます。This can be null
if no arguments are needed.
戻り値
呼び出されているデリゲートからの戻り値。デリゲートに戻り値がない場合は null
。The return value from the delegate being invoked or null
if the delegate has no return value.
- 属性
例外
priority
が有効な優先順位ではありません。priority
is not a valid priority.
method
が null
です。method
is null
.
注釈
arg``null
引数が不要な場合は、にすることができます。arg
can be null
if an argument is not needed
WPF では、を作成したスレッドだけ DispatcherObject がそのオブジェクトにアクセスできます。In WPF, only the thread that created a DispatcherObject may access that object. たとえば、メイン UI スレッドからスピンオフされたバックグラウンドスレッドは、 Button ui スレッドで作成されたの内容を更新できません。For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. バックグラウンドスレッドがの Content プロパティにアクセスするためには、 Button Dispatcher UI スレッドに関連付けられているに作業を委任する必要があります。In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. これは、またはを使用して行い Invoke BeginInvoke ます。This is accomplished by using either Invoke or BeginInvoke. Invoke は同期的であり、 BeginInvoke 非同期です。Invoke is synchronous and BeginInvoke is asynchronous. 操作は、指定したののイベントキューに追加され Dispatcher DispatcherPriority ます。The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke は同期操作です。そのため、コールバックが戻るまで、コントロールは呼び出し元のオブジェクトに戻りません。Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
適用対象
Invoke(DispatcherPriority, Delegate, Object, Object[])
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で同期的に実行します。Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(System::Windows::Threading::DispatcherPriority priority, Delegate ^ method, System::Object ^ arg, ... cli::array <System::Object ^> ^ args);
[System.ComponentModel.Browsable(false)]
public object Invoke (System.Windows.Threading.DispatcherPriority priority, Delegate method, object arg, params object[] args);
[<System.ComponentModel.Browsable(false)>]
member this.Invoke : System.Windows.Threading.DispatcherPriority * Delegate * obj * obj[] -> obj
Public Function Invoke (priority As DispatcherPriority, method As Delegate, arg As Object, ParamArray args As Object()) As Object
パラメーター
- priority
- DispatcherPriority
Dispatcher指定されたメソッドが呼び出される、イベントキュー内の他の保留中の操作を基準とする優先順位。The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- method
- Delegate
複数の引数を受け取るメソッドへのデリゲート。このデリゲートは、Dispatcher イベント キューにプッシュされます。A delegate to a method that takes multiple arguments, which is pushed onto the Dispatcher event queue.
- arg
- Object
指定したメソッドに引数として渡すオブジェクト。An object to pass as an argument to the given method.
- args
- Object[]
特定のメソッドに引数として渡すオブジェクトの配列。An array of objects to pass as arguments to the given method.
戻り値
呼び出されているデリゲートからの戻り値。デリゲートに戻り値がない場合は null
。The return value from the delegate being invoked or null
if the delegate has no return value.
- 属性
例外
priority
が有効な優先順位ではありません。priority
is not a valid priority.
method
が null
です。method
is null
.
注釈
arg``null
引数が不要な場合は、にすることができます。arg
can be null
if an argument is not needed
WPF では、を作成したスレッドだけ DispatcherObject がそのオブジェクトにアクセスできます。In WPF, only the thread that created a DispatcherObject may access that object. たとえば、メイン UI スレッドからスピンオフされたバックグラウンドスレッドは、 Button ui スレッドで作成されたの内容を更新できません。For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. バックグラウンドスレッドがの Content プロパティにアクセスするためには、 Button Dispatcher UI スレッドに関連付けられているに作業を委任する必要があります。In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. これは、またはを使用して行い Invoke BeginInvoke ます。This is accomplished by using either Invoke or BeginInvoke. Invoke は同期的であり、 BeginInvoke 非同期です。Invoke is synchronous and BeginInvoke is asynchronous. 操作は、指定したののイベントキューに追加され Dispatcher DispatcherPriority ます。The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke は同期操作です。そのため、コールバックが戻るまで、コントロールは呼び出し元のオブジェクトに戻りません。Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
適用対象
Invoke(Action, DispatcherPriority, CancellationToken, TimeSpan)
Action が関連付けられているスレッドで、指定した Dispatcher を指定した優先順位で同期的に実行します。Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with.
public:
void Invoke(Action ^ callback, System::Windows::Threading::DispatcherPriority priority, System::Threading::CancellationToken cancellationToken, TimeSpan timeout);
public void Invoke (Action callback, System.Windows.Threading.DispatcherPriority priority, System.Threading.CancellationToken cancellationToken, TimeSpan timeout);
member this.Invoke : Action * System.Windows.Threading.DispatcherPriority * System.Threading.CancellationToken * TimeSpan -> unit
Public Sub Invoke (callback As Action, priority As DispatcherPriority, cancellationToken As CancellationToken, timeout As TimeSpan)
パラメーター
- callback
- Action
ディスパッチャーを通じて呼び出すアクションデリゲート。An Action delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
指定されたコールバックが、内の他の保留中の操作に対して相対的に呼び出される順序を決定する優先順位 Dispatcher 。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.
- timeout
- TimeSpan
操作の開始を待機する最大時間。The maximum amount of time to wait for the operation to start. 操作が開始されると、このメソッドが戻る前に完了します。Once the operation has started, it will complete before this method returns. 無期限の待機を指定するには、値-1 を使用します。To specify an infinite wait, use a value of -1. 同じスレッド呼び出しでは、その他の負の値は-1 に変換され、その結果、待機時間が無制限になります。In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. スレッド間の呼び出しでは、他の負の値がをスロー ArgumentOutOfRangeException します。In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
例外
callback
が null
です。callback
is null
.
timeout
が-1 以外の負の数値です。このメソッドはスレッド間で呼び出されました。timeout
is a negative number other than -1, and this method was invoked across threads.
priority
が有効な優先順位ではありません。priority
is not a valid priority.
適用対象
Invoke(DispatcherPriority, TimeSpan, Delegate)
Dispatcher が作成されたスレッドで、指定したタイムアウトの値を使用して、指定したデリゲートを指定した優先順位で同期的に実行します。Executes the specified delegate synchronously at the specified priority and with the specified time-out value on the thread the Dispatcher was created.
public:
System::Object ^ Invoke(System::Windows::Threading::DispatcherPriority priority, TimeSpan timeout, Delegate ^ method);
[System.ComponentModel.Browsable(false)]
public object Invoke (System.Windows.Threading.DispatcherPriority priority, TimeSpan timeout, Delegate method);
[<System.ComponentModel.Browsable(false)>]
member this.Invoke : System.Windows.Threading.DispatcherPriority * TimeSpan * Delegate -> obj
Public Function Invoke (priority As DispatcherPriority, timeout As TimeSpan, method As Delegate) As Object
パラメーター
- priority
- DispatcherPriority
Dispatcher指定されたメソッドが呼び出される、イベントキュー内の他の保留中の操作を基準とする優先順位。The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- timeout
- TimeSpan
操作の開始を待機する最大時間。The maximum amount of time to wait for the operation to start. 操作が開始されると、このメソッドが戻る前に完了します。Once the operation has started, it will complete before this method returns. 無期限の待機を指定するには、値-1 を使用します。To specify an infinite wait, use a value of -1. 同じスレッド呼び出しでは、その他の負の値は-1 に変換され、その結果、待機時間が無制限になります。In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. スレッド間の呼び出しでは、他の負の値がをスロー ArgumentOutOfRangeException します。In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- method
- Delegate
引数を受け取らないメソッドへのデリゲート。このデリゲートは、Dispatcher イベント キューにプッシュされます。The delegate to a method that takes no arguments, which is pushed onto the Dispatcher event queue.
戻り値
呼び出されているデリゲートからの戻り値。デリゲートに戻り値がない場合は null
。The return value from the delegate being invoked or null
if the delegate has no return value.
- 属性
例外
method
が null
です。method
is null
.
timeout
が-1 以外の負の数値です。このメソッドはスレッド間で呼び出されました。timeout
is a negative number other than -1, and this method was invoked across threads.
priority
が有効な優先順位ではありません。priority
is not a valid priority.
注釈
WPF では、を作成したスレッドだけ DispatcherObject がそのオブジェクトにアクセスできます。In WPF, only the thread that created a DispatcherObject may access that object. たとえば、メイン UI スレッドからスピンオフされたバックグラウンドスレッドは、 Button ui スレッドで作成されたの内容を更新できません。For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. バックグラウンドスレッドがの Content プロパティにアクセスするためには、 Button Dispatcher UI スレッドに関連付けられているに作業を委任する必要があります。In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. これは、またはを使用して行い Invoke BeginInvoke ます。This is accomplished by using either Invoke or BeginInvoke. Invoke は同期的であり、 BeginInvoke 非同期です。Invoke is synchronous and BeginInvoke is asynchronous. 操作は、指定したののイベントキューに追加され Dispatcher DispatcherPriority ます。The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke は同期操作です。そのため、コールバックが戻るまで、コントロールは呼び出し元のオブジェクトに戻りません。Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
適用対象
Invoke(DispatcherPriority, Delegate, Object)
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で同期的に実行します。Executes the specified delegate at the specified priority with the specified argument synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(System::Windows::Threading::DispatcherPriority priority, Delegate ^ method, System::Object ^ arg);
[System.ComponentModel.Browsable(false)]
public object Invoke (System.Windows.Threading.DispatcherPriority priority, Delegate method, object arg);
[<System.ComponentModel.Browsable(false)>]
member this.Invoke : System.Windows.Threading.DispatcherPriority * Delegate * obj -> obj
Public Function Invoke (priority As DispatcherPriority, method As Delegate, arg As Object) As Object
パラメーター
- priority
- DispatcherPriority
Dispatcher指定されたメソッドが呼び出される、イベントキュー内の他の保留中の操作を基準とする優先順位。The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- method
- Delegate
引数を 1 つ受け取るメソッドへのデリゲート。このデリゲートは、Dispatcher イベント キューにプッシュされます。A delegate to a method that takes one argument, which is pushed onto the Dispatcher event queue.
- arg
- Object
指定したメソッドに引数として渡すオブジェクト。An object to pass as an argument to the given method.
戻り値
呼び出されているデリゲートからの戻り値。デリゲートに戻り値がない場合は null
。The return value from the delegate being invoked or null
if the delegate has no return value.
- 属性
例外
priority
が有効な優先順位ではありません。priority
is not a valid priority.
method
が null
です。method
is null
.
注釈
arg``null
引数が不要な場合は、にすることができます。arg
can be null
if an argument is not needed
WPF では、を作成したスレッドだけ DispatcherObject がそのオブジェクトにアクセスできます。In WPF, only the thread that created a DispatcherObject may access that object. たとえば、メイン UI スレッドからスピンオフされたバックグラウンドスレッドは、 Button ui スレッドで作成されたの内容を更新できません。For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. バックグラウンドスレッドがの Content プロパティにアクセスするためには、 Button Dispatcher UI スレッドに関連付けられているに作業を委任する必要があります。In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. これは、またはを使用して行い Invoke BeginInvoke ます。This is accomplished by using either Invoke or BeginInvoke. Invoke は同期的であり、 BeginInvoke 非同期です。Invoke is synchronous and BeginInvoke is asynchronous. 操作は、指定したののイベントキューに追加され Dispatcher DispatcherPriority ます。The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke は同期操作です。そのため、コールバックが戻るまで、コントロールは呼び出し元のオブジェクトに戻りません。Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
適用対象
Invoke(Delegate, TimeSpan, DispatcherPriority, Object[])
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で、指定した期間内に同期的に実行します。Executes the specified delegate within the designated time span at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(Delegate ^ method, TimeSpan timeout, System::Windows::Threading::DispatcherPriority priority, ... cli::array <System::Object ^> ^ args);
public object Invoke (Delegate method, TimeSpan timeout, System.Windows.Threading.DispatcherPriority priority, params object[] args);
member this.Invoke : Delegate * TimeSpan * System.Windows.Threading.DispatcherPriority * obj[] -> obj
Public Function Invoke (method As Delegate, timeout As TimeSpan, priority As DispatcherPriority, ParamArray args As Object()) As Object
パラメーター
- method
- Delegate
args
で指定したパラメーターを受け取るメソッドへのデリゲート。このデリゲートは、Dispatcher イベント キューにプッシュされます。A delegate to a method that takes parameters specified in args
, which is pushed onto the Dispatcher event queue.
- timeout
- TimeSpan
操作の開始を待機する最大時間。The maximum amount of time to wait for the operation to start. 操作が開始されると、このメソッドが戻る前に完了します。Once the operation has started, it will complete before this method returns. 無期限の待機を指定するには、値-1 を使用します。To specify an infinite wait, use a value of -1. 同じスレッド呼び出しでは、その他の負の値は-1 に変換され、その結果、待機時間が無制限になります。In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. スレッド間の呼び出しでは、他の負の値がをスロー ArgumentOutOfRangeException します。In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- priority
- DispatcherPriority
Dispatcher指定されたメソッドが呼び出される、イベントキュー内の他の保留中の操作を基準とする優先順位。The priority, relative to the other pending operations in the Dispatcher event queue, with which the specified method is invoked.
- args
- Object[]
特定のメソッドに引数として渡すオブジェクトの配列。An array of objects to pass as arguments to the given method. null
の可能性があります。Can be null
.
戻り値
呼び出されているデリゲートからの戻り値。デリゲートに戻り値がない場合は null
。The return value from the delegate being invoked or null
if the delegate has no return value.
例外
method
が null
です。method
is null
.
timeout
が-1 以外の負の数値です。このメソッドはスレッド間で呼び出されました。timeout
is a negative number other than -1, and this method was invoked across threads.
priority
が有効な優先順位ではありません。priority
is not a valid priority.
注釈
WPF では、を作成したスレッドだけ DispatcherObject がそのオブジェクトにアクセスできます。In WPF, only the thread that created a DispatcherObject may access that object. たとえば、メイン UI スレッドからスピンオフされたバックグラウンドスレッドは、 Button ui スレッドで作成されたの内容を更新できません。For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. バックグラウンドスレッドがの Content プロパティにアクセスするためには、 Button Dispatcher UI スレッドに関連付けられているに作業を委任する必要があります。In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. これは、またはを使用して行い Invoke BeginInvoke ます。This is accomplished by using either Invoke or BeginInvoke. Invoke は同期的であり、 BeginInvoke 非同期です。Invoke is synchronous and BeginInvoke is asynchronous. 操作は、指定したののイベントキューに追加され Dispatcher DispatcherPriority ます。The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke は同期操作です。そのため、コールバックが戻るまで、コントロールは呼び出し元のオブジェクトに戻りません。Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
適用対象
Invoke(Delegate, TimeSpan, Object[])
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で、指定した期間内に同期的に実行します。Executes the specified delegate within the designated time span at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(Delegate ^ method, TimeSpan timeout, ... cli::array <System::Object ^> ^ args);
public object Invoke (Delegate method, TimeSpan timeout, params object[] args);
member this.Invoke : Delegate * TimeSpan * obj[] -> obj
Public Function Invoke (method As Delegate, timeout As TimeSpan, ParamArray args As Object()) As Object
パラメーター
- method
- Delegate
args
で指定したパラメーターを受け取るメソッドへのデリゲート。このデリゲートは、Dispatcher イベント キューにプッシュされます。A delegate to a method that takes parameters specified in args
, which is pushed onto the Dispatcher event queue.
- timeout
- TimeSpan
操作の開始を待機する最大時間。The maximum amount of time to wait for the operation to start. ただし、操作が開始されると、このメソッドが戻る前に完了します。However, once the operation starts, it will complete before this method returns. 無期限の待機を指定するには、値-1 を使用します。To specify an infinite wait, use a value of -1. 同じスレッド呼び出しでは、その他の負の値は-1 に変換され、その結果、待機時間が無制限になります。In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. スレッド間の呼び出しでは、他の負の値がをスロー ArgumentOutOfRangeException します。In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
- args
- Object[]
特定のメソッドに引数として渡すオブジェクトの配列。An array of objects to pass as arguments to the given method. null
引数が不要な場合は、を指定できます。Can be null
if no arguments are needed.
戻り値
呼び出されているデリゲートからの戻り値。デリゲートに戻り値がない場合は null
。The return value from the delegate being invoked or null
if the delegate has no return value.
例外
method
が null
です。method
is null
.
timeout
は-1 以外の負の数値であり、スレッド間で呼び出されています。timeout
is a negative number other than -1, and you're invoking across threads.
注釈
WPF では、を作成したスレッドだけ DispatcherObject がそのオブジェクトにアクセスできます。In WPF, only the thread that created a DispatcherObject may access that object. たとえば、メイン UI スレッドからスピンオフされたバックグラウンドスレッドは、 Button ui スレッドで作成されたの内容を更新できません。For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. バックグラウンドスレッドがの Content プロパティにアクセスするためには、 Button Dispatcher UI スレッドに関連付けられているに作業を委任する必要があります。In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. これは、またはを使用して行い Invoke BeginInvoke ます。This is accomplished by using either Invoke or BeginInvoke. Invoke は同期的であり、 BeginInvoke 非同期です。Invoke is synchronous and BeginInvoke is asynchronous. 操作は、指定したののイベントキューに追加され Dispatcher DispatcherPriority ます。The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke は同期操作です。そのため、コールバックが戻るまで、コントロールは呼び出し元のオブジェクトに戻りません。Invoke is a synchronous operation; therefore, control won't return to the calling object until after the callback returns.
適用対象
Invoke(Action, DispatcherPriority, CancellationToken)
Action が関連付けられているスレッドで、指定した Dispatcher を指定した優先順位で同期的に実行します。Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with.
public:
void Invoke(Action ^ callback, System::Windows::Threading::DispatcherPriority priority, System::Threading::CancellationToken cancellationToken);
public void Invoke (Action callback, System.Windows.Threading.DispatcherPriority priority, System.Threading.CancellationToken cancellationToken);
member this.Invoke : Action * System.Windows.Threading.DispatcherPriority * System.Threading.CancellationToken -> unit
Public Sub Invoke (callback As Action, priority As DispatcherPriority, cancellationToken As CancellationToken)
パラメーター
- callback
- Action
ディスパッチャーを通じて呼び出すデリゲート。A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
指定されたコールバックが、内の他の保留中の操作に対して相対的に呼び出される順序を決定する優先順位 Dispatcher 。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.
適用対象
Invoke(DispatcherPriority, Delegate)
が関連付けられているスレッドで、指定したデリゲートを指定した優先順位で同期的に実行し Dispatcher ます。Executes the specified delegate synchronously at the specified priority on the thread that the Dispatcher is associated with.
public:
System::Object ^ Invoke(System::Windows::Threading::DispatcherPriority priority, Delegate ^ method);
[System.ComponentModel.Browsable(false)]
public object Invoke (System.Windows.Threading.DispatcherPriority priority, Delegate method);
[<System.ComponentModel.Browsable(false)>]
member this.Invoke : System.Windows.Threading.DispatcherPriority * Delegate -> obj
Public Function Invoke (priority As DispatcherPriority, method As Delegate) As Object
パラメーター
- priority
- DispatcherPriority
指定したメソッドの呼び出しに使用する優先順位。イベントキュー内の他の保留中の操作を基準とし Dispatcher ます。The priority with which the specified method is invoked, relative to the other pending operations in the Dispatcher event queue.
- method
- Delegate
引数を受け取らないメソッドへのデリゲート。このデリゲートは、Dispatcher イベント キューにプッシュされます。A delegate to a method that takes no arguments, which is pushed onto the Dispatcher event queue.
戻り値
呼び出されているデリゲートからの戻り値。デリゲートに戻り値がない場合は null
。The return value from the delegate being invoked or null
if the delegate has no return value.
- 属性
例外
priority
が有効な優先順位ではありません。priority
is not a valid priority.
method
が null
です。method
is null
.
例
次の例では、を使用して、にデリゲートをに配置し Dispatcher Normal Invoke ます。The following example places a delegate onto a Dispatcher at Normal using Invoke.
// Places the delegate onto the UI Thread's Dispatcher
private void timer_Elapsed(object sender, ElapsedEventArgs e)
{
// Place delegate on the Dispatcher.
this.Dispatcher.Invoke(DispatcherPriority.Normal,
new TimerDispatcherDelegate(TimerWorkItem));
}
' Places the delegate onto the UI Thread's Dispatcher
Private Sub timer_Elapsed(ByVal sender As Object, ByVal e As ElapsedEventArgs)
' Place delegate on the Dispatcher.
Me.Dispatcher.Invoke(DispatcherPriority.Normal, New TimerDispatcherDelegate(AddressOf TimerWorkItem))
End Sub
注釈
WPF では、を作成したスレッドだけ DispatcherObject がそのオブジェクトにアクセスできます。In WPF, only the thread that created a DispatcherObject may access that object. たとえば、メイン UI スレッドからスピンオフされたバックグラウンドスレッドは、 Button ui スレッドで作成されたの内容を更新できません。For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. バックグラウンドスレッドがの Content プロパティにアクセスするためには、 Button Dispatcher UI スレッドに関連付けられているに作業を委任する必要があります。In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. これは、またはを使用して行い Invoke BeginInvoke ます。This is accomplished by using either Invoke or BeginInvoke. Invoke は同期的であり、 BeginInvoke 非同期です。Invoke is synchronous and BeginInvoke is asynchronous. 操作は、指定したののイベントキューに追加され Dispatcher DispatcherPriority ます。The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke は同期操作です。そのため、コールバックが戻るまで、コントロールは呼び出し元のオブジェクトに戻りません。Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
適用対象
Invoke(Delegate, Object[])
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを同期的に実行します。Executes the specified delegate with the specified arguments synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(Delegate ^ method, ... cli::array <System::Object ^> ^ args);
public object Invoke (Delegate method, params object[] args);
member this.Invoke : Delegate * obj[] -> obj
Public Function Invoke (method As Delegate, ParamArray args As Object()) As Object
パラメーター
- method
- Delegate
args
で指定したパラメーターを受け取るメソッドへのデリゲート。このデリゲートは、Dispatcher イベント キューにプッシュされます。A delegate to a method that takes parameters specified in args
, which is pushed onto the Dispatcher event queue.
- args
- Object[]
特定のメソッドに引数として渡すオブジェクトの配列。An array of objects to pass as arguments to the given method. null
の可能性があります。Can be null
.
戻り値
呼び出されているデリゲートからの戻り値。デリゲートに戻り値がない場合は null
。The return value from the delegate being invoked or null
if the delegate has no return value.
注釈
WPF では、を作成したスレッドだけ DispatcherObject がそのオブジェクトにアクセスできます。In WPF, only the thread that created a DispatcherObject may access that object. たとえば、メイン UI スレッドからスピンオフされたバックグラウンドスレッドは、 Button ui スレッドで作成されたの内容を更新できません。For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. バックグラウンドスレッドがの Content プロパティにアクセスするためには、 Button Dispatcher UI スレッドに関連付けられているに作業を委任する必要があります。In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. これは、またはを使用して行い Invoke BeginInvoke ます。This is accomplished by using either Invoke or BeginInvoke. Invoke は同期的であり、 BeginInvoke 非同期です。Invoke is synchronous and BeginInvoke is asynchronous. 操作は、指定したののイベントキューに追加され Dispatcher DispatcherPriority ます。The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke は同期操作です。そのため、コールバックが戻るまで、コントロールは呼び出し元のオブジェクトに戻りません。Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
適用対象
Invoke(Action, DispatcherPriority)
Action が関連付けられているスレッドで、指定した Dispatcher を指定した優先順位で同期的に実行します。Executes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with.
public:
void Invoke(Action ^ callback, System::Windows::Threading::DispatcherPriority priority);
public void Invoke (Action callback, System.Windows.Threading.DispatcherPriority priority);
member this.Invoke : Action * System.Windows.Threading.DispatcherPriority -> unit
Public Sub Invoke (callback As Action, priority As DispatcherPriority)
パラメーター
- callback
- Action
ディスパッチャーを通じて呼び出すデリゲート。A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
指定されたコールバックが、内の他の保留中の操作に対して相対的に呼び出される順序を決定する優先順位 Dispatcher 。The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.
適用対象
Invoke(Action)
Action が関連付けられているスレッドで、指定した Dispatcher を同期的に実行します。Executes the specified Action synchronously on the thread the Dispatcher is associated with.
public:
void Invoke(Action ^ callback);
public void Invoke (Action callback);
member this.Invoke : Action -> unit
Public Sub Invoke (callback As Action)
パラメーター
- callback
- Action
ディスパッチャーを通じて呼び出すデリゲート。A delegate to invoke through the dispatcher.
適用対象
Invoke(Delegate, DispatcherPriority, Object[])
Dispatcher が関連付けられているスレッドで、指定した引数を使用して、指定したデリゲートを指定した優先順位で同期的に実行します。Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with.
public:
System::Object ^ Invoke(Delegate ^ method, System::Windows::Threading::DispatcherPriority priority, ... cli::array <System::Object ^> ^ args);
public object Invoke (Delegate method, System.Windows.Threading.DispatcherPriority priority, params object[] args);
member this.Invoke : Delegate * System.Windows.Threading.DispatcherPriority * obj[] -> obj
Public Function Invoke (method As Delegate, priority As DispatcherPriority, ParamArray args As Object()) As Object
パラメーター
- method
- Delegate
args
で指定したパラメーターを受け取るメソッドへのデリゲート。このデリゲートは、Dispatcher イベント キューにプッシュされます。A delegate to a method that takes parameters specified in args
, which is pushed onto the Dispatcher event queue.
- priority
- DispatcherPriority
指定したメソッドの呼び出しに使用する優先順位。イベントキュー内の他の保留中の操作を基準とし Dispatcher ます。The priority with which the specified method is invoked, relative to the other pending operations in the Dispatcher event queue.
- args
- Object[]
特定のメソッドに引数として渡すオブジェクトの配列。An array of objects to pass as arguments to the given method. null
の可能性があります。Can be null
.
戻り値
呼び出されているデリゲートからの戻り値。デリゲートに戻り値がない場合は null
。The return value from the delegate being invoked or null
if the delegate has no return value.
注釈
WPF では、を作成したスレッドだけ DispatcherObject がそのオブジェクトにアクセスできます。In WPF, only the thread that created a DispatcherObject may access that object. たとえば、メイン UI スレッドからスピンオフされたバックグラウンドスレッドは、 Button ui スレッドで作成されたの内容を更新できません。For example, a background thread that is spun off from the main UI thread cannot update the contents of a Button that was created on the UI thread. バックグラウンドスレッドがの Content プロパティにアクセスするためには、 Button Dispatcher UI スレッドに関連付けられているに作業を委任する必要があります。In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. これは、またはを使用して行い Invoke BeginInvoke ます。This is accomplished by using either Invoke or BeginInvoke. Invoke は同期的であり、 BeginInvoke 非同期です。Invoke is synchronous and BeginInvoke is asynchronous. 操作は、指定したののイベントキューに追加され Dispatcher DispatcherPriority ます。The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.
Invoke は同期操作です。そのため、コールバックが戻るまで、コントロールは呼び出し元のオブジェクトに戻りません。Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.
適用対象
Invoke<TResult>(Func<TResult>)
Func<TResult> が関連付けられているスレッドで、指定した Dispatcher を同期的に実行します。Executes the specified Func<TResult> synchronously on the thread the Dispatcher is associated with.
public:
generic <typename TResult>
TResult Invoke(Func<TResult> ^ callback);
public TResult Invoke<TResult> (Func<TResult> callback);
member this.Invoke : Func<'Result> -> 'Result
Public Function Invoke(Of TResult) (callback As Func(Of TResult)) As TResult
型パラメーター
- TResult
指定されたデリゲートの戻り値の型。The return value type of the specified delegate.
パラメーター
- callback
- Func<TResult>
ディスパッチャーを通じて呼び出すデリゲート。A delegate to invoke through the dispatcher.
戻り値
- TResult
によって返される値 callback
。The value returned by callback
.
適用対象
Invoke<TResult>(Func<TResult>, DispatcherPriority)
Func<TResult> が関連付けられているスレッドで、指定した Dispatcher を指定した優先順位で同期的に実行します。Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with.
public:
generic <typename TResult>
TResult Invoke(Func<TResult> ^ callback, System::Windows::Threading::DispatcherPriority priority);
public TResult Invoke<TResult> (Func<TResult> callback, System.Windows.Threading.DispatcherPriority priority);
member this.Invoke : Func<'Result> * System.Windows.Threading.DispatcherPriority -> 'Result
Public Function Invoke(Of TResult) (callback As Func(Of TResult), priority As DispatcherPriority) As TResult
型パラメーター
- TResult
指定されたデリゲートの戻り値の型。The return value type of the specified delegate.
パラメーター
- callback
- Func<TResult>
ディスパッチャーを通じて呼び出すデリゲート。A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
指定されたコールバックが、内の他の保留中の操作に対して相対的に呼び出される順序を決定する優先順位 Dispatcher 。The priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.
戻り値
- TResult
によって返される値 callback
。The value returned by callback
.
適用対象
Invoke<TResult>(Func<TResult>, DispatcherPriority, CancellationToken)
Func<TResult> が関連付けられているスレッドで、指定した Dispatcher を指定した優先順位で同期的に実行します。Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with.
public:
generic <typename TResult>
TResult Invoke(Func<TResult> ^ callback, System::Windows::Threading::DispatcherPriority priority, System::Threading::CancellationToken cancellationToken);
public TResult Invoke<TResult> (Func<TResult> callback, System.Windows.Threading.DispatcherPriority priority, System.Threading.CancellationToken cancellationToken);
member this.Invoke : Func<'Result> * System.Windows.Threading.DispatcherPriority * System.Threading.CancellationToken -> 'Result
Public Function Invoke(Of TResult) (callback As Func(Of TResult), priority As DispatcherPriority, cancellationToken As CancellationToken) As TResult
型パラメーター
- TResult
指定されたデリゲートの戻り値の型。The return value type of the specified delegate.
パラメーター
- callback
- Func<TResult>
ディスパッチャーを通じて呼び出すデリゲート。A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
指定されたコールバックが、内の他の保留中の操作に対して相対的に呼び出される順序を決定する優先順位 Dispatcher 。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.
戻り値
- TResult
によって返される値 callback
。The value returned by callback
.
適用対象
Invoke<TResult>(Func<TResult>, DispatcherPriority, CancellationToken, TimeSpan)
Func<TResult> が関連付けられているスレッドで、指定した Dispatcher を指定した優先順位で同期的に実行します。Executes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with.
public:
generic <typename TResult>
TResult Invoke(Func<TResult> ^ callback, System::Windows::Threading::DispatcherPriority priority, System::Threading::CancellationToken cancellationToken, TimeSpan timeout);
public TResult Invoke<TResult> (Func<TResult> callback, System.Windows.Threading.DispatcherPriority priority, System.Threading.CancellationToken cancellationToken, TimeSpan timeout);
member this.Invoke : Func<'Result> * System.Windows.Threading.DispatcherPriority * System.Threading.CancellationToken * TimeSpan -> 'Result
Public Function Invoke(Of TResult) (callback As Func(Of TResult), priority As DispatcherPriority, cancellationToken As CancellationToken, timeout As TimeSpan) As TResult
型パラメーター
- TResult
指定されたデリゲートの戻り値の型。The return value type of the specified delegate.
パラメーター
- callback
- Func<TResult>
ディスパッチャーを通じて呼び出すデリゲート。A delegate to invoke through the dispatcher.
- priority
- DispatcherPriority
指定されたコールバックが、内の他の保留中の操作に対して相対的に呼び出される順序を決定する優先順位 Dispatcher 。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.
- timeout
- TimeSpan
操作の開始を待機する最大時間。The maximum amount of time to wait for the operation to start. 操作が開始されると、このメソッドが戻る前に完了します。Once the operation has started, it will complete before this method returns. 無期限の待機を指定するには、値-1 を使用します。To specify an infinite wait, use a value of -1. 同じスレッド呼び出しでは、その他の負の値は-1 に変換され、その結果、待機時間が無制限になります。In a same-thread call, any other negative value is converted to -1, resulting in an infinite wait. スレッド間の呼び出しでは、他の負の値がをスロー ArgumentOutOfRangeException します。In a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.
戻り値
- TResult
によって返される値 callback
。The value returned by callback
.
例外
callback
が null
です。callback
is null
.
timeout
が-1 以外の負の数値です。メソッドがスレッド間で呼び出されました。timeout
is a negative number other than -1, and the method was invoked across threads.
priority
が有効な優先順位ではありません。priority
is not a valid priority.