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 相關聯的執行緒上使用指定優先權同步執行指定的 DispatcherExecutes 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 相關聯的執行緒上使用指定優先權同步執行指定的 DispatcherExecutes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with.

Invoke(DispatcherPriority, Delegate)

在與相關聯的執行緒上,以指定的優先權同步執行指定的委派 DispatcherExecutes 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 相關聯的執行緒上使用指定優先權同步執行指定的 DispatcherExecutes the specified Action synchronously at the specified priority on the thread the Dispatcher is associated with.

Invoke(Action)

在與 Action 相關聯的執行緒上,同步執行指定的 DispatcherExecutes 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> 相關聯的執行緒上,同步執行指定的 DispatcherExecutes the specified Func<TResult> synchronously on the thread the Dispatcher is associated with.

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

在與 Func<TResult> 相關聯的執行緒上使用指定優先權同步執行指定的 DispatcherExecutes 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> 相關聯的執行緒上使用指定優先權同步執行指定的 DispatcherExecutes 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> 相關聯的執行緒上使用指定優先權同步執行指定的 DispatcherExecutes the specified Func<TResult> synchronously at the specified priority on the thread the Dispatcher is associated with.

範例

下列範例會使用將委派放 Dispatcher 在上 Normal InvokeThe 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 BeginInvokeThis is accomplished by using either Invoke or BeginInvoke. Invoke 是同步的,而且 BeginInvoke 是非同步。Invoke is synchronous and BeginInvoke is asynchronous. 作業會加入至指定之的事件佇列中 Dispatcher DispatcherPriorityThe 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. 在跨執行緒呼叫中,任何其他負值都會擲回 ArgumentOutOfRangeExceptionIn 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.

傳回

Object

來自所叫用的委派的傳回值,或者如果委派沒有任何傳回值,則為 nullThe return value from the delegate being invoked or null if the delegate has no return value.

屬性

例外狀況

priority 等於 Inactivepriority is equal to Inactive.

priority 不是有效的 DispatcherPrioritypriority is not a valid DispatcherPriority.

methodnullmethod 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 BeginInvokeThis is accomplished by using either Invoke or BeginInvoke. Invoke 是同步的,而且 BeginInvoke 是非同步。Invoke is synchronous and BeginInvoke is asynchronous. 作業會加入至指定之的事件佇列中 Dispatcher DispatcherPriorityThe 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. 在跨執行緒呼叫中,任何其他負值都會擲回 ArgumentOutOfRangeExceptionIn 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. 如果不需要引數,則這個可為 nullThis can be null if no arguments are needed.

傳回

Object

來自所叫用的委派的傳回值,或者如果委派沒有任何傳回值,則為 nullThe return value from the delegate being invoked or null if the delegate has no return value.

屬性

例外狀況

priority 等於 Inactivepriority is equal to Inactive.

priority 不是有效的優先權。priority is not a valid priority.

methodnullmethod 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 BeginInvokeThis is accomplished by using either Invoke or BeginInvoke. Invoke 是同步的,而且 BeginInvoke 是非同步。Invoke is synchronous and BeginInvoke is asynchronous. 作業會加入至指定之的事件佇列中 Dispatcher DispatcherPriorityThe 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.

傳回

Object

來自所叫用的委派的傳回值,或者如果委派沒有任何傳回值,則為 nullThe return value from the delegate being invoked or null if the delegate has no return value.

屬性

例外狀況

priority 等於 Inactivepriority is equal to Inactive.

priority 不是有效的優先權。priority is not a valid priority.

methodnullmethod 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 BeginInvokeThis is accomplished by using either Invoke or BeginInvoke. Invoke 是同步的,而且 BeginInvoke 是非同步。Invoke is synchronous and BeginInvoke is asynchronous. 作業會加入至指定之的事件佇列中 Dispatcher DispatcherPriorityThe 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 相關聯的執行緒上使用指定優先權同步執行指定的 DispatcherExecutes 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

決定叫用指定回呼之順序的優先順序,相對於中的其他暫止作業 DispatcherThe 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. 在跨執行緒呼叫中,任何其他負值都會擲回 ArgumentOutOfRangeExceptionIn a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.

例外狀況

callbacknullcallback 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. 在跨執行緒呼叫中,任何其他負值都會擲回 ArgumentOutOfRangeExceptionIn 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.

傳回

Object

來自所叫用的委派的傳回值,或者如果委派沒有任何傳回值,則為 nullThe return value from the delegate being invoked or null if the delegate has no return value.

屬性

例外狀況

methodnullmethod is null.

timeout 是-1 以外的負數,而且會跨執行緒叫用此方法。timeout is a negative number other than -1, and this method was invoked across threads.

priority 等於 Inactivepriority is equal to Inactive.

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 BeginInvokeThis is accomplished by using either Invoke or BeginInvoke. Invoke 是同步的,而且 BeginInvoke 是非同步。Invoke is synchronous and BeginInvoke is asynchronous. 作業會加入至指定之的事件佇列中 Dispatcher DispatcherPriorityThe 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

採用一個引數的方法委派,此委派會推入至 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.

傳回

Object

來自所叫用的委派的傳回值,或者如果委派沒有任何傳回值,則為 nullThe return value from the delegate being invoked or null if the delegate has no return value.

屬性

例外狀況

priority 等於 Inactivepriority is equal to Inactive.

priority 不是有效的優先權。priority is not a valid priority.

methodnullmethod 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 BeginInvokeThis is accomplished by using either Invoke or BeginInvoke. Invoke 是同步的,而且 BeginInvoke 是非同步。Invoke is synchronous and BeginInvoke is asynchronous. 作業會加入至指定之的事件佇列中 Dispatcher DispatcherPriorityThe 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. 在跨執行緒呼叫中,任何其他負值都會擲回 ArgumentOutOfRangeExceptionIn 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. 可以是 nullCan be null.

傳回

Object

來自所叫用的委派的傳回值,或者如果委派沒有任何傳回值,則為 nullThe return value from the delegate being invoked or null if the delegate has no return value.

例外狀況

methodnullmethod is null.

timeout 是-1 以外的負數,而且會跨執行緒叫用此方法。timeout is a negative number other than -1, and this method was invoked across threads.

priority 等於 Inactivepriority is equal to Inactive.

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 BeginInvokeThis is accomplished by using either Invoke or BeginInvoke. Invoke 是同步的,而且 BeginInvoke 是非同步。Invoke is synchronous and BeginInvoke is asynchronous. 作業會加入至指定之的事件佇列中 Dispatcher DispatcherPriorityThe 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. 在跨執行緒呼叫中,任何其他負值都會擲回 ArgumentOutOfRangeExceptionIn 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.

傳回

Object

來自所叫用的委派的傳回值,或者如果委派沒有任何傳回值,則為 nullThe return value from the delegate being invoked or null if the delegate has no return value.

例外狀況

methodnullmethod 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 BeginInvokeThis is accomplished by using either Invoke or BeginInvoke. Invoke 是同步的,而且 BeginInvoke 是非同步。Invoke is synchronous and BeginInvoke is asynchronous. 作業會加入至指定之的事件佇列中 Dispatcher DispatcherPriorityThe 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 相關聯的執行緒上使用指定優先權同步執行指定的 DispatcherExecutes 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

決定叫用指定回呼之順序的優先順序,相對於中的其他暫止作業 DispatcherThe 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)

在與相關聯的執行緒上,以指定的優先權同步執行指定的委派 DispatcherExecutes 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

用來叫用指定方法的優先順序,相對於事件佇列中的其他暫止作業 DispatcherThe 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.

傳回

Object

來自所叫用的委派的傳回值,或者如果委派沒有任何傳回值,則為 nullThe return value from the delegate being invoked or null if the delegate has no return value.

屬性

例外狀況

priority 等於 Inactivepriority is equal to Inactive.

priority 不是有效的優先權。priority is not a valid priority.

methodnullmethod is null.

範例

下列範例會使用將委派放 Dispatcher 在上 Normal InvokeThe 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 BeginInvokeThis is accomplished by using either Invoke or BeginInvoke. Invoke 是同步的,而且 BeginInvoke 是非同步。Invoke is synchronous and BeginInvoke is asynchronous. 作業會加入至指定之的事件佇列中 Dispatcher DispatcherPriorityThe 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. 可以是 nullCan be null.

傳回

Object

來自所叫用的委派的傳回值,或者如果委派沒有任何傳回值,則為 nullThe 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 BeginInvokeThis is accomplished by using either Invoke or BeginInvoke. Invoke 是同步的,而且 BeginInvoke 是非同步。Invoke is synchronous and BeginInvoke is asynchronous. 作業會加入至指定之的事件佇列中 Dispatcher DispatcherPriorityThe 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 相關聯的執行緒上使用指定優先權同步執行指定的 DispatcherExecutes 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

決定叫用指定回呼之順序的優先順序,相對於中的其他暫止作業 DispatcherThe priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.

適用於

Invoke(Action)

在與 Action 相關聯的執行緒上,同步執行指定的 DispatcherExecutes 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

用來叫用指定方法的優先順序,相對於事件佇列中的其他暫止作業 DispatcherThe 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. 可以是 nullCan be null.

傳回

Object

來自所叫用的委派的傳回值,或者如果委派沒有任何傳回值,則為 nullThe 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 BeginInvokeThis is accomplished by using either Invoke or BeginInvoke. Invoke 是同步的,而且 BeginInvoke 是非同步。Invoke is synchronous and BeginInvoke is asynchronous. 作業會加入至指定之的事件佇列中 Dispatcher DispatcherPriorityThe 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> 相關聯的執行緒上,同步執行指定的 DispatcherExecutes 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

所傳回的值 callbackThe value returned by callback.

適用於

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

在與 Func<TResult> 相關聯的執行緒上使用指定優先權同步執行指定的 DispatcherExecutes 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

決定叫用指定回呼之順序的優先順序,相對於中的其他暫止作業 DispatcherThe priority that determines the order in which the specified callback is invoked relative to the other pending operations in the Dispatcher.

傳回

TResult

所傳回的值 callbackThe value returned by callback.

適用於

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

在與 Func<TResult> 相關聯的執行緒上使用指定優先權同步執行指定的 DispatcherExecutes 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

決定叫用指定回呼之順序的優先順序,相對於中的其他暫止作業 DispatcherThe 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

所傳回的值 callbackThe value returned by callback.

適用於

Invoke<TResult>(Func<TResult>, DispatcherPriority, CancellationToken, TimeSpan)

在與 Func<TResult> 相關聯的執行緒上使用指定優先權同步執行指定的 DispatcherExecutes 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

決定叫用指定回呼之順序的優先順序,相對於中的其他暫止作業 DispatcherThe 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. 在跨執行緒呼叫中,任何其他負值都會擲回 ArgumentOutOfRangeExceptionIn a cross-thread call, any other negative value throws an ArgumentOutOfRangeException.

傳回

TResult

所傳回的值 callbackThe value returned by callback.

例外狀況

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

適用於