VBNet 如何知道后台工作程序是否已被取消
目前,我有以下代码: My_BgWorkerB 是我的 BackGround Worker 的名称
If My_BgWorkerB.IsBusy Then
If My_BgWorkerB.WorkerSupportsCancellation Then
My_BgWorkerB.CancelAsync()
End If
' in this part i want to know if the background worker is already stopped
' so that i can start it again
' My_BgWorkerB.RunWorkerAsync() ' => this should be triggered if the worker
' has already been stop.
Else
My_BgWorkerB.RunWorkerAsync()
End If
currently, i have this code: My_BgWorkerB is the Name of my BackGround Worker
If My_BgWorkerB.IsBusy Then
If My_BgWorkerB.WorkerSupportsCancellation Then
My_BgWorkerB.CancelAsync()
End If
' in this part i want to know if the background worker is already stopped
' so that i can start it again
' My_BgWorkerB.RunWorkerAsync() ' => this should be triggered if the worker
' has already been stop.
Else
My_BgWorkerB.RunWorkerAsync()
End If
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该做的是检查
RunWorkerCompletedEventArgs
像这样的事情:
What you should do is check the
RunWorkerCompletedEventArgs
Cancelled property in your BGW'sRunWorkerCompleted
event handler. If it's true restart your BGW using theRunWorkerAsync()
method.Something like this: