I have heard from a very discerning person that an exception being thrown (and not caught) in a thread is being propagated to the parent thread. Is that true? I have tried some
Here is one way of catching it and handling it in a safe way:
BackgroundWorker bg = new BackgroundWorker();
object o;
bg.DoWork += (c1,c2) =>
{
Thread.Sleep(2000);
throw new IndexOutOfRangeException();
};
bg.RunWorkerCompleted += (c3,c4) =>
{
if (((RunWorkerCompletedEventArgs)e).Error != null)
{
MessageBox.Show(((RunWorkerCompletedEventArgs)e).Error.Message);
}
};