我有一个usercontrol和两个类,我想将我的class1的结果打印到usercontrol.I我正在使用这一行从类发送结果
((merge.MyControl)(MyControlInstance)).CLIDisplay = e.WorkItem.CustomerId;
Run Code Online (Sandbox Code Playgroud)
我的控件属性显示结果是
public string CLIDisplay
{
get { return lblResultCLI.Text; }
set
{
lblResultCLI.Text = value;
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我把一个类调到我的c#表单时,我得到了Exception
An exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll but was not handled in user code
Additional information: Cross-thread operation not valid: Control 'tbxEvents' accessed from a thread other than the thread it was created on.
Run Code Online (Sandbox Code Playgroud)