Hello,
I'm experiencing a problem in which an exception in a background thread jumps out of its Try/Catch block and gets handled by the application's unhandled exception handler.
I have a class that calls an overridden method (InitializeBatch) in a derived class, and it's wrapped in a Try/Catch block like this:
Public Sub Execute()
...
Try
Try
InitializeBatch()
...
Try
RaiseEvent BatchBeginning(Me, New EventArgs)
ExecuteBatch()
...
Catch ex As Exception
_TerminationCause = CauseForTermination.Failed
_FailureException = New BatchProcessFailedException(ex)
End Try
Catch ex As Exception
_TerminationCause = CauseForTermination.InitializationFailed
_FailureException = New BatchInitializeException(ex)
End Try
Finally
_Running = False
RaiseEvent BatchTerminated(Me, New EventArgs)
End Try
End Sub
My windows forms app launches this process like this:
With New Threading.Thread(AddressOf _BatchProcess.Execute)
.Name = "SMOPS_BatchProcessThread"
.IsBackground = True
.Start()
End With
For whatever reason, an exception thrown in InitializeBatch() isn't caught in the Try/Catch. Execution branches from the exception straight to the unhandled exception handler. An exception thrown in ExecuteBatch() is handled properly. I've checked and double checked, and nothing on this thread is touching the form or any controls. Is there any other common (or less common) error that could be causing this?
Thanks
Scott
I'm experiencing a problem in which an exception in a background thread jumps out of its Try/Catch block and gets handled by the application's unhandled exception handler.
I have a class that calls an overridden method (InitializeBatch) in a derived class, and it's wrapped in a Try/Catch block like this:
Public Sub Execute()
...
Try
Try
InitializeBatch()
...
Try
RaiseEvent BatchBeginning(Me, New EventArgs)
ExecuteBatch()
...
Catch ex As Exception
_TerminationCause = CauseForTermination.Failed
_FailureException = New BatchProcessFailedException(ex)
End Try
Catch ex As Exception
_TerminationCause = CauseForTermination.InitializationFailed
_FailureException = New BatchInitializeException(ex)
End Try
Finally
_Running = False
RaiseEvent BatchTerminated(Me, New EventArgs)
End Try
End Sub
My windows forms app launches this process like this:
With New Threading.Thread(AddressOf _BatchProcess.Execute)
.Name = "SMOPS_BatchProcessThread"
.IsBackground = True
.Start()
End With
For whatever reason, an exception thrown in InitializeBatch() isn't caught in the Try/Catch. Execution branches from the exception straight to the unhandled exception handler. An exception thrown in ExecuteBatch() is handled properly. I've checked and double checked, and nothing on this thread is touching the form or any controls. Is there any other common (or less common) error that could be causing this?
Thanks
Scott