在一个项目中,我使用的是 Backgroundworker(在 vb.net 中)。我在 Windows 8 Pro(64 位)下工作,项目在它上面运行良好......但是如果我在 Windows 7(64 位)的机器上传输可执行文件,就会发生奇怪的事情!Backgroundworker 的 DoWork 不起作用,它直接跳到 RunWorkerCompleted。我不明白为什么。我用 Visual Studio 2012 Express Edition 编译它。你有解决这个问题的想法吗?谢谢你。
这是一些代码:
Private Sub bgw_extract_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles bgw_extract.DoWork
MsgBox("test dowork") 'this appear
extract_cycle() 'this isn't executed
MsgBox("end dowork") 'this isn't executed
End Sub
Private Sub extract_cycle()
'nothing is executed here
MsgBox("test2") 'not executed
Try
'my code....
Catch ex As Exception
MessageBox.Show(ex.ToString(), "Extract Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub bgw_extract_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles
bgw_extract.RunWorkerCompleted
MsgBox("RunWorkCompleted") 'this is executed in every case
End Sub