ISynchronizeInvoke.Invoke(Delegate, Object[]) 方法

定义

在创建了此对象的线程上同步执行委托并封送对创建线程的调用。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,在控件的线程上下文中。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.

适用于