I am running an application that, when not used, just sits there firing a
BackgroundWorker every 20 seconds. Every now and then, the BackgroundWorker
freezes between the DoWork and RunWorkerCompleted procedures. My simplified
procedures are shown below. They endlessly write messages to a text file.
At some point it never moves from DoWork to RunWorkerCompleted. I do have
services such as Outlook and Norton SystemWorks running in the background.
Any ideas why the BackgroundWorker freezes between these procedures for no
apparent reason. Could it be some other background service causing the
problem? It has never ran a complete day without freezing.
Each of these procedures has error trapping that shows a message if there is
an error. I never see the message indicating that whatever is happening is
not caused by a trappable error.
Private Sub BackgroundWorker1_DoWork(XXXX) Handles BackgroundWorker1.DoWork
C.DoMsg(Now & " BackgroundWorker1_DoWork -2")
C.DoMsg(Now & " BackgroundWorker1_DoWork Finish")
End Sub
Private Sub BackgroundWorker1_RunWorkerCompleted(XXXX) Handles
BackgroundWorker1.RunWorkerCompleted
C.DoMsg(Now & " BackgroundWorker1_RunWorkerCompleted Start")
C.DoMsg(Now & " BackgroundWorker1_RunWorkerCompleted Finish")
End Sub
Friend Sub DoMsg(ByVal psMsg As String)
Debug.Print(psMsg)
Dim oSW As StreamWriter = New StreamWriter("C:\Temp\AppMsg.txt", pbAppend)
oSW.WriteLine(psMsg)
oSW.Close()
End Sub
My code in the timer is:
If Not BackgroundWorker1.IsBusy Then
Me.BackgroundWorker1.RunWorkerAsync()
End If
********Sample log.
6/14/2006 1:13:39 AM BackgroundWorker1_RunWorkerCompleted Finish
tmrAutoRecover_Tick
6/14/2006 1:13:39 AM BackgroundWorker1_DoWork -2
6/14/2006 1:13:39 AM BackgroundWorker1_DoWork Finish
6/14/2006 1:13:39 AM BackgroundWorker1_RunWorkerCompleted Start
6/14/2006 1:13:39 AM BackgroundWorker1_RunWorkerCompleted Finish
tmrAutoRecover_Tick
6/14/2006 1:13:51 AM BackgroundWorker1_DoWork -2
6/14/2006 1:13:51 AM BackgroundWorker1_DoWork Finish
6/14/2006 1:13:51 AM BackgroundWorker1_RunWorkerCompleted Start
6/14/2006 1:13:51 AM BackgroundWorker1_RunWorkerCompleted Finish
tmrAutoRecover_Tick
6/14/2006 1:14:07 AM BackgroundWorker1_DoWork -2
6/14/2006 1:14:07 AM BackgroundWorker1_DoWork Finish
********Log stops at this point, Application is frozen.