【发布时间】:2012-08-22 21:59:43
【问题描述】:
可能重复:
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
我的线程有问题。
我每 600 毫秒从 COM 端口获取数据,当我处于调试模式时,我会在几秒钟后收到错误消息,但是当我处于非调试运行模式时,我会在一两分钟后收到错误消息,但错误仍然存在。
我得到的错误发生在每个线程上调用的某些函数上。
这是错误的图片:
其他部分代码:
private void LoadData()
{
while (td.IsAlive)
{
eng.GetSpeedKmh();
eng.GetEngineRpm();
eng.GetCalculatedEngineLoadValue();
eng.GetFuelLevelInput();
eng.GetEngineTemp();
eng.MAF();
System.Threading.Thread.Sleep(600);
}
}
我能做些什么来解决这个问题?
【问题讨论】:
-
错误信息告诉你所有你可能想知道的。
-
@DavidSchwartz:我想他们也想知道如何解决这个问题。
-
@Jon:错误消息包含“疑难解答提示”下的信息。
标签: c# multithreading