Error Help: Cross-thread operation not valid: Control ” accessed from a thread other than the thread it was created on–accessed-from-a-thread-other-than-the-thread-it-was-created-on.aspx

Joe inquired about Cross-thread operation not valid: Control ” accessed from a thread other than the thread it was created on. Joe, Amar, Jeta, and Willy Denoyette [MVP] believed EventHandler, ThreadPool, EventArgs, BeginInvoke, and Control may be crucial. In fact, Thread, Win32, and Stack may also be significant.
I’ve been getting this message at all different times since a few days ago.

I understand the message but not why I get it. I don’t have any other


This happens when closing dialog boxes, doing a drag and drop and a few

other things which I don’t remember right now.

It only happens while I’m running within the IDE and only seems to be on my

computer. We’ve tested the same thing on other machines running VS.2005 and

there is no problem.

Any ideas? I’m thinking I need to reinstall VS.




Amar chimed in with hello joe.

Reinstalling VS wont solve the problem.

The problem you are facing is because microsoft finally decided to

enforce strict restriction on cross thread acces of control..(i.e you

cannot acces the control from other threads than on which it was

created on)

There are two solutions for this..

1> The lengthy and the better solution ..

Using the InvokeRequired property of the control.


private void Form1_Load(object sender, EventArgs e)




this.Invoke(new EventHandler(Form1_Load), new object[]

{sender, e});



//Your code here…



Just set the Control.CheckForIllegalCrossThreadCalls property to


This willstop the exception being thrown but wont solve the problem.

I would recommend the first way.

jeta mentioned hi Joe ,
Amar has provided the detailed correct reply to you.
Note: Microsoft enforces this restriction to help us to detect the invalid
operation: accessing the UI control methods/properties from another thread.
This is the GUI threading rule, which is introduced by history reason(.Net
Winform controls encapsulates Win32 controls which are COM STA threading
model. This threading model requires the accessing to the controls can only
be allowed from the creating thread).
So the first solution is highly recommended and second way is turning off
the Microsoft's help.
Best regards,
Jeffrey Tan
Microsoft Online Community Support

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s