Possible Duplicate:
Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on.
Greeting, I'm trying to update button status from a thread and I'm getting this error:
"Cross-thread operation not valid: Control 'btn1' accessed from a thread other than the thread it was created on."
please advice how to fix this problem.
here is my code:
if (strMyPlayer == "Player One")
{
if (srReceiver.ReadLine() == "Player One says: btn1")
{
btn1.Text = "O";
btn1.Enabled = false;
}
}
else
{
if (srReceiver.ReadLine() == "btn1")
{
btn1.Text = "X";
btn1.Enabled = false;
}
}