Hi All,
I'm playing with the BackgroundWorker control, and am having a little
trouble figuring out Exception Handling. MSDN makes it sound so simple - if
an exception is thrown in DoWork, then e.Error should not be null.
However, I can't get DoWork to process an exception "properly". I always
get an Unhandled Exception error.
For instance, here's the simplest case:
private void BGWorker_DoWork(object sender, DoWorkEventArgs e)
{
// I can never get past here
throw new ApplicationException("This is an exception");
}
private void BGWorker_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
MessageBox.Show("There was an error: " + e.Error.Message);
}
My searches online seem to indicate that other people have had similar
problems, but I haven't found a workaround, solution, or whether this is
considered a bug.
Any help is much appreciated.
Thanks,
PAGates