Monday, April 2, 2012

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

This error is occurring when  you are going to access the UI with another thread. There are method you can use to over come this situation.

The best approach is to use method Invoker to update the UI when it is required.

if (txtDataRx.InvokeRequired)
new MethodInvoker(delegate { txtDataRx.Text = txtDataRx.Text + szData; }));
txtDataRx.Text = txtDataRx.Text + szData;
Post a Comment