C# 错误:跨线程操作无效

C# 错误:跨线程操作无效,c#,multithreading,C#,Multithreading,下面的代码给了我一个错误:“跨线程操作无效:控件'textBox30'是从创建它的线程以外的线程访问的。” 有人能提出解决方案吗?这似乎是调用者需要解决的问题 而不是: textBox30.Text = index.ToString(); 尝试: 更多信息:如果(textBox30.invokererequired){this.Invoke(((MethodInvoker)委托{textBox30.Text=index.ToString();}));//返回;},我会这样写 textBox30

下面的代码给了我一个错误:“跨线程操作无效:控件'textBox30'是从创建它的线程以外的线程访问的。”


有人能提出解决方案吗?

这似乎是调用者需要解决的问题

而不是:

textBox30.Text = index.ToString();
尝试:

更多信息:

如果(textBox30.invokererequired){this.Invoke(((MethodInvoker)委托{textBox30.Text=index.ToString();}));//返回;},我会这样写
textBox30.Text = index.ToString();
textBox30.Invoke(s => textBox30.Text = s, index.ToString())