Throwing error back to main thread
If I create a STA thread to do work, but an error occurs, how do I propagate the error back to the calling thread?
private void Form1_Load(object sender, System.EventArgs e)
{
Thread t = new Thread(new ThreadStart(ThreadProc));
t.ApartmentState = ApartmentState.STA;
t.Start();
t.Join();
MessageBox.Show("Done");
Application.Exit();
}
private void ThreadProc()
{
try
{
throw new Exception("Test Bomb");
}
catch (Exception ex)
{
// Rethrow error to calling thread
}
}
|