Multiple UI Threads – Winforms

Messing with threads will only bite you sooner or later.

From MSDN:

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

You can of course use as many threads as you like, but don’t try to create a workaround to be able to use different threads for updating the UI. Use Invoke/InvokeRequired from your worker/background threads instead.

Using an extension method makes it cleaner: Automating the InvokeRequired code pattern

Leave a Comment