我正在閱讀肥皂呼叫DataTable
需要很長時間才能完成。爲了讓GUI保持活動狀態並更新選取框進度條,我可以在後臺工作人員上執行soapcall並等待它在Runworkercompleted
子文件中設置全局變量標誌。 該表填充得當,並且dowork返回,但完成的runworker永遠不會被調用。vb.net Backgroundworker DoWork沒有結束
如果我重新編寫這個設置標誌爲DoWork的最後一件事,然後下一次我打電話TableGetterThread.RunWorkerAsync
它告訴我,它不能運行的任務,同時 (附加信息:這BackgroundWorker
當前正忙,不能同時運行多個任務。 )
任何幫助我做錯了很多讚賞。
waiting = True
TableGetterThread.RunWorkerAsync(New tableInfo(tablename, filter))
While waiting
Me.Refresh()
Threading.Thread.Sleep(100)
End While
Private Sub TableGetterThread_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles TableGetterThread.DoWork
Dim user As String = "username"
Dim pass As String = "password"
getTable_Table = Nothing
getTable_Table = bromcomReader.getEntityData(e.Argument.tablename, e.Argument.Filter, user, pass).Tables(0)
getTable_Table.TableName = e.Argument.tablename
Console.WriteLine("FinishedDoWork")
End Sub
Private Sub TableGetterThread_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles TableGetterThread.RunWorkerCompleted
Console.WriteLine("Completed")
waiting = False
End Sub
從DoWork代碼中刪除'Console.WriteLine(「FinishedDoWork」)''。 – 2014-12-19 10:21:46
相同的效果,只是稍後添加,以確保代碼不掛在bromcomReader.getEntityData() – Peterp 2014-12-19 10:26:24
認爲你的while循環是問題。那之後會發生什麼?你不能在RunWorkerCOmpleted Sub的wihle循環之後調用這些東西嗎? – 2014-12-19 12:18:47