當我存取權限內BackgroundWorker
DoWork
事件表單控件,它的DatePicker讀值,但不能從文本框或組合框錯誤的BackgroundWorker的DoWork事件中讀取組合框的值時
錯誤:
Cross-thread operation not valid: Control 'cmbProgram' accessed from a thread other than the thread it was created on.
代碼:
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
string strDate = dtpDate.Value.ToString();
string strProgram = cmbProgram.Text;
}
它是如何讀取DataPicker值(在不同的線程)?
有任何解決方法從BackgroundWorker
DoWork
事件訪問窗體控件?