好的..这是问题
我有一个主 UI 表单,它有一个控件容器,我可以向它添加一些按钮项,而且我还有一个启动侦听器的 backgroundworker 对象。当侦听器事件触发时,我想在主 UI 表单上的该控件容器中创建一个按钮。在我尝试向该容器添加新的控件项之前,一切似乎都运行良好。我得到以下异常
“跨线程操作无效:控制 'RadMagnifier_AcceptReject' 从创建它的线程以外的线程访问。”
代码像这样流动
Private Sub Mainform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.SessionTableAdapter.Fill(Me.BCSSDataSet1.Session)
FormatColumns()
Me.BackgroundWorker2.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker2_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker2.DoWork
Notifications()
End Sub
Private Sub Notifications()
'Start listing for events when event is fired try to add a button to a controls container on the UI thread, and that when i get the problem
End Sub