Hi
I have an application which uses a backgroundWorker to do a simple file copy whilst the main UI is doing some other work.
The problem is that the RunWorkerCompleted event does not always fire and I can see no pattern as to when it may or may not work.
The BGW resides on the UI form and has these properties-
WorkerReportsProgress = false
WorkerSupportsCancellation = true
The form code simply calls Me.bgWorkerWMVexport.RunWorkerAsync()
Private Sub bgWorkerWMVExport_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgWorkerWMVexport.DoWork
Try
If Me.bgWorkerWMVexport.CancellationPending Then Return
If My.Settings.webExport Then 'export wmv to web folder
exportWeb(strWorkFileName + ".wmv")
End If
e.Result = "ok"
Catch ex As Exception
e.Result = ex.Message
End Try
End Sub
Private Sub bgWorkerWMVExport_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bgWorkerWMVexport.RunWorkerCompleted
bWmvExport = True
If Not e.Result.ToString & "" = "" Then
MsgBox(e.Result)
End If
End Sub
The code always completes the DoWork sub and never produces an exception.
The code seldom enters the RunWorkerCompleted sub but thats totally random.
Anyone have any clues what's going on?