我有一个后台工作人员运行循环查询数据库,直到返回一个值。它需要在加载和刷新时启动。上载似乎运行良好,但当我再次调用它失败“BackgroundWorker目前正忙,无法同时运行多个任务”BackgroundWorker当前正忙,无法同时运行多个任务
我添加了backgroundworker到我的表单,添加了它需要做的工作事件。
Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles bgwProcessResource.DoWork
Logic.SetConnection(connectionString)
materialConfirmed = False
Dim sqlManager As New BOMIDatabaseManager(connectionString)
Dim currentInstance As New ResourceInstance(resource, instance)
Dim results As New Hashtable
status = Logic.ProcessResource(currentInstance)
While status.woID.Count <= 0
status = Logic.ProcessResource(currentInstance)
End While
currentWO = status.woID(0)
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As System.Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bgwProcessResource.RunWorkerCompleted
WaitingForm.Close()
'Me.Enabled = False
currentWO = status.woID(0)
controller.SelectWorkOrder(status.woID(0), "20")
End Sub
它刷新它必须已经完成,所以我不知道它为什么说它很忙。
后异常的堆栈跟踪。 –
为每个新任务使用新的后台工作人员。听起来你试图重复使用相同的后台工作人员 –
正确,我使用工具栏项目创建了一个。 – asdfasfd