This documentation is archived and is not being maintained.

Control.InvokeRequired Property

Gets a value indicating whether the caller must call an invoke method when making method calls to the control because the caller is on a different thread than the one the control was created on.

[Visual Basic]
Public Overridable ReadOnly Property InvokeRequired As Boolean  _
   Implements ISynchronizeInvoke.InvokeRequired
[C#]
public virtual bool InvokeRequired {get;}
[C++]
public: __property virtual bool get_InvokeRequired();
[JScript]
public function get InvokeRequired() : Boolean;

Property Value

true if the control's Handle was created on a different thread than the calling thread (indicating that you must make calls to the control through an invoke method); otherwise, false.

Implements

ISynchronizeInvoke.InvokeRequired

Remarks

Controls in Windows Forms are bound to a specific thread and are not thread safe. Therefore, if you are calling a control's method from a different thread, you must use one of the control's invoke methods to marshal the call to the proper thread. This property can be used to determine if you must call an invoke method, which can be useful if you do not know what thread owns a control. 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 these invoke methods when calling from a different thread.

For more information about multithreaded Windows Forms controls, see Multithreaded Windows Forms Control Sample.

Requirements

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 | Invoke | InvokeGotFocus | InvokeLostFocus | InvokeOnClick | InvokePaint | InvokePaintBackground

Show: