Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From your background thread, you should use <code>Control.InvokeRequired</code> and <code>Control.Invoke</code> in order to cause the UI thread to execute the code that updates the UI.</p> <p>Only the UI thread is allowed to "touch" control properties, so your background thread cannot update them.</p> <p>To be more specific, in case you're interesting in more details: in Windows, each form and control usually have 1 or more HWND associated with them. An HWND is a handle to the Windows operating system object representing a Windows window.</p> <p>Each HWND is always associated to a specific thread, the thread that created it. Any Windows message sent to that HWND will reach that thread's message queue and must be handled by that thread's message loop.</p> <p>When you make seemingly innocent calls to Controls methods, the implementation of these methods might sometime destroy and create HWND under the hood (for example, creating a submenu for a Menu control or adding a button to a Toolbar control). Now, if you were to make such calls from different threads, you would end up with HWNDs belonging to different threads, and the processing of your controls' messages would be broken.</p> <p>For that reason, all access to controls' methods are prohibited from any thread other than the thread that created the control's HWND (e.g. the thread on which `Control.CreateControl() was called).</p> <p>In the bottom line, for most simple applications, the main thread is the only one creating windows, and so you should be touching Forms and Controls only from your main thread.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload