This documentation is archived and is not being maintained.

Control.Invoke Method (Delegate, Object[])

.NET Framework 1.1

Executes the specified delegate, on the thread that owns the control's underlying window handle, with the specified list of arguments.

[Visual Basic]
Overloads Public Overridable Function Invoke( _
   ByVal method As Delegate, _
   ByVal args() As Object _
) As Object Implements ISynchronizeInvoke.Invoke
public virtual object Invoke(
 Delegate method,
 object[] args
public: virtual Object* Invoke(
 Delegate* method,
 Object* args __gc[]
public function Invoke(
   method : Delegate,
 args : Object[]
) : Object;


A delegate to a method that takes parameters of the same number and type that are contained in the args parameter.
An array of objects to pass as arguments to the specified method. This parameter can be a null reference (Nothing in Visual Basic) if the method takes no arguments.

Return Value

An Object that contains the return value from the delegate being invoked, or a null reference (Nothing in Visual Basic) if the delegate has no return value.




If the control's handle does not exist yet, this method searches up the control's parent chain until it finds a control or form that does have a window handle. If no appropriate handle can be found, the Invoke method will throw an exception. Exceptions that are raised during the call will be propagated back to the caller.

Note   There are four methods on a control that are safe to call from any thread: Invoke, BeginInvoke, EndInvoke, and CreateGraphics. For all other method calls, you should use one of the invoke methods to marshal the call to the control's thread.

The delegate can be an instance of EventHandler, in which case the sender parameter will contain this control, and the event parameter will contain EventArgs.Empty. The delegate can also be an instance of MethodInvoker, or any other delegate that takes a void parameter list. A call to an EventHandler or MethodInvoker delegate will be faster than a call to another type of delegate.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Control Class | Control Members | System.Windows.Forms Namespace | Control.Invoke Overload List | MethodInvoker | InvokeRequired