我有一個用戶控件和兩個班我想打印我的Class1的結果爲usercontrol.I是從類利用該線路發送結果用戶控件拋出異常「跨線程操作無效」
((merge.MyControl)(MyControlInstance)).CLIDisplay = e.WorkItem.CustomerId;
我的控制屬性顯示的結果是
public string CLIDisplay
{
get { return lblResultCLI.Text; }
set
{
lblResultCLI.Text = value;
}
}
,但我得到以下情況例外,當我打電話一類我的C#形式
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.
你還沒有解釋你在線程方面做了什麼,這顯然很重要。你對這個錯誤做了什麼研究? –
錯誤是關於'tbxEvents',這是代碼中缺少的一種。 –
[Cross-thread operation not valid:可從其創建的線程以外的線程訪問的控制]的可能重複(http://stackoverflow.com/questions/142003/cross-thread-operation-not-valid-control -ac-threads-other-than-the) – slugster