Multi-Threading with Windows Forms Control

This problem will happen to anyone that uses threads. When trying to call a Form control from a Thread, the debugger raises an InvalidOperationException with the message, "Control control name accessed from a thread other than the thread it was created on."
Why Microsoft add this feature in VS 2005 ?
When it's enabled (you can manipulated control through threads), it is possible to force the control into an inconsistent state when it's controled by more than one thread.
So you can Disable this feature simply by adding this line of code :
CheckForIllegalCrossThreadCalls = false
Where to add ?
Open the Form Designer and put this line in the Private Sub InitializeComponent()
I get this idea from Anima Blog,


Post a Comment