By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,925 Members | 727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,925 IT Pros & Developers. It's quick & easy.

Cross-thread operation not valid

P: n/a
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

Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You cannot access controls of the form from another thread directly, instead
of this you have to use async delegates.

Here you can find some explanations
http://weblogs.asp.net/justin_rogers...es/126345.aspx

--
Vadym Stetsyak aka Vadmyst
"Mikael Syska" <ne****@syska.dk> wrote in message
news:O$**************@TK2MSFTNGP15.phx.gbl...
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

Nov 17 '05 #2

P: n/a
Mikael Syska <ne****@syska.dk> wrote:
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

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.