Multithreading with Forms and Controls
Collapse the table of content
Expand the table of content
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 Invoke to call 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

© 2016 Microsoft