BackgroundWorker
DoWork
当我在事件中 访问表单控件时,它会从DatePicker读取值,但不会从TextBox或ComboBox读取值
错误:
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
事件访问表单控件?