Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 状态带交叉线程错误_C#_Multithreading_Winforms - Fatal编程技术网

C# 状态带交叉线程错误

C# 状态带交叉线程错误,c#,multithreading,winforms,C#,Multithreading,Winforms,我已经检查了我的代码并加入了调用程序,在本部分之前,这些调用程序运行得非常好: Invoke(new MethodInvoker(() => { statusLabel.ForeColor = Color.Red; statusLabel.Text = "Pausing..."; System.Threading.Thread.Sleep(10000); statusLabel.ForeColor = Color.Black; })); 我有一个s

我已经检查了我的代码并加入了调用程序,在本部分之前,这些调用程序运行得非常好:

Invoke(new MethodInvoker(() =>
{
    statusLabel.ForeColor = Color.Red;
    statusLabel.Text = "Pausing...";
    System.Threading.Thread.Sleep(10000);
    statusLabel.ForeColor = Color.Black;    
}));

我有一个statusStrip,其中有一个statusLabel我在statusStrip上遇到了一个跨线程错误我从来没有访问statusStrip,只有statusLabel.text部分,我在这里做错了什么吗?

如果您在访问statusStrip时遇到错误,这不是导致您出现问题的代码。您实际在哪里访问statusStrip?实际的异常是什么,哪行抛出它?发布stacktrace。除了将UI线程冻结10秒之外,您到底遇到了什么错误?异常文本是什么,包括它的堆栈跟踪?