HowTo pass exception from background thread to main thread?

  • Thread starter Thread starter Prozon
  • Start date Start date
P

Prozon

Hi!
I´m starting a background thread in my application that may cause an
exception anf if so I want the main thread to catch it. How can I do
that?
This is my code:

public sub save()
try
Dim t As New Thread(AddressOf ThreadMethodSave)
t.Start()
Catch ex As Exception
Throw ex
end try
end sub

Public Sub ThreadMethodSave()
Try
Dim i As Integer = 0
Dim j As Integer = 1
i = j / i ' Just a test to se if exceptions can be handled
' Do some useful work
Catch ex As Exception
Throw ex
End Try
End Sub



The exception is catched in ThreadMethodSave. But howto pass it back
to main thread?

Best Regards
/ Steve
 
Back
Top