ISynchronizeInvoke.Invoke(Delegate, Object[]) ISynchronizeInvoke.Invoke(Delegate, Object[]) ISynchronizeInvoke.Invoke(Delegate, Object[]) ISynchronizeInvoke.Invoke(Delegate, Object[]) Method

定義

在建立此物件的執行緒上同步執行委派,並封送處理對建立執行緒的呼叫。Synchronously executes the delegate on the thread that created this object and marshals the call to the creating thread.

public:
 System::Object ^ Invoke(Delegate ^ method, cli::array <System::Object ^> ^ args);
public object Invoke (Delegate method, object[] args);
abstract member Invoke : Delegate * obj[] -> obj
Public Function Invoke (method As Delegate, args As Object()) As Object

參數

method
Delegate Delegate Delegate Delegate

Delegate,含有了要呼叫的方法,在控制項執行緒的內容中。A Delegate that contains a method to call, in the context of the thread for the control.

args
Object[]

Object 型別的陣列,表示要傳遞至指定方法的引數。An array of type Object that represents the arguments to pass to the given method. 如果不需要引數,則這個可為 nullThis can be null if no arguments are needed.

傳回

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

備註

BeginInvoke不同的是, 這個方法會同步操作, 也就是說, 它會等到進程完成, 然後再傳回。Unlike BeginInvoke, this method operates synchronously, that is, it waits until the process completes before returning. 呼叫期間引發的例外狀況會傳播回呼叫端。Exceptions raised during the call are propagated back to the caller.

從不同的執行緒呼叫方法時, 請使用這個方法, 將呼叫封送處理至適當的執行緒。Use this method when calling a method from a different thread to marshal the call to the proper thread.

適用於