Possible Duplicate:
Why am I getting this error:“Cross-thread operation not valid: Control lbFolders accessed from a thread other than the thread it was created on.”?
Invoke or BeginInvoke cannot be called on a control until the window handle has been created
I have problem with threads.
I am fetching data from COM port every 600ms and when I'm in debug mode I am getting error like after few seconds but when I am in non-debug running mode I am getting error after minute or two but error persist.
The error that I am getting is occurring on some of the functions that are called on each thread.
Here is the picture of the error:
Other part of the code:
private void LoadData()
{
while (td.IsAlive)
{
eng.GetSpeedKmh();
eng.GetEngineRpm();
eng.GetCalculatedEngineLoadValue();
eng.GetFuelLevelInput();
eng.GetEngineTemp();
eng.MAF();
System.Threading.Thread.Sleep(600);
}
}
What can I do to fix this?