This documentation is archived and is not being maintained.

Multithreading with Forms and Controls

While multithreading is best suited to running procedures and class methods, you can also use it with forms and controls. If you do so, be aware of the following points:

  • Whenever possible, execute the methods of a control only on the thread with which it was created. If you must call a method of a control from another thread, you must use the Control.Invoke style of calling the method.
  • Do not use the SyncLock statement to lock threads that manipulate controls or forms. Because the methods of controls and forms sometimes call back to a calling procedure, you can end up inadvertently creating a deadlock — a situation in which two threads wait for each other to release the lock, causing the application to halt.

See Also

Control.Invoke Method | Control.InvokeRequired Property | Thread States | Parameters and Return Values for Multithreaded Procedures| Multithreaded Applications | Multithreading in Components