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

Posted by Rajujrk under C# on 3/31/2010 | Views : 3526 | Status : [Member] | Replies : 0
I am Having a problem on the below code..
In Windows Application...

Here pan2 is a Panel Control

[code]
private void ThreadTask()
{
while (true)
{
Thread.Sleep(2000);
double time = hr + (min * 0.016712299);
double kmhr = Convert.ToInt32(Txtkm.Text) * 1.609344;
double distance = kmhr * time;
distance = distance - distanc;
x = Convert.ToInt32((distance / 10.0)) - x3;
y = Convert.ToInt32((distance / 10.0)) - y3;
pan2.Refresh();
}
}
[/code]

[code]
Error Message is
Cross-thread operation not valid: Control 'pan2' accessed from a thread other than the thread it was created on.
[/code]

Thanks & Regards

Rajkumar J



Responses

(No response found.)

Login to post response