Multithreading Errors in C#

Posted by Adam on Stack Overflow See other posts from Stack Overflow or by Adam
Published on 2010-04-08T04:23:05Z Indexed on 2010/04/08 4:33 UTC
Read the original article Hit count: 313

Filed under:
|
|

Hi. I am trying to update a text box. I thought my threading code would fix the problem, but it does not. Can anyone help with this?

new Thread((ThreadStart)delegate { txtCapacitance.Text = Math.Round(capacitance, 3).ToString(); }).Start();

Gives the following error:

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

Note that all this is being started by a dataReceived function which is called whenever USB data is received.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET