Cross-thread operation not valid

  • Thread starter Thread starter Mikael Syska
  • Start date Start date
M

Mikael Syska

Hey,

Cross-thread operation not valid: Control 'ThreadStartedAt' accessed
from a thread other than the thread it was created on

I get this Exception when I try to update some labels/textbox's from a
Thread... I have read something about that I can use Delegates/Invoke
and stuff in that direction, but I'm not that far in my book now that I
understand how all that works....

Is there any one here that can give a very simple example, I can use in
my Program to update some controls on my form from a Thread?

// ouT
 
Mikael Syska said:
Cross-thread operation not valid: Control 'ThreadStartedAt' accessed
from a thread other than the thread it was created on

I get this Exception when I try to update some labels/textbox's from a
Thread... I have read something about that I can use Delegates/Invoke
and stuff in that direction, but I'm not that far in my book now that I
understand how all that works....

Is there any one here that can give a very simple example, I can use in
my Program to update some controls on my form from a Thread?

You can't, directly. You have to call Control.Invoke/BeginInvoke to do
the actual update on the UI thread.

See http://www.pobox.com/~skeet/csharp/winforms.shtml
 
Back
Top