Has anyone else noticed that even though you handle an exception that
happens within the background worker that the UnhandledExcept ion event
still fires?
For example, here's my ThreadException hookup and code :
Application.Thr eadException += new
ThreadException EventHandler(Ap plication_Threa dException);
void Application_Thr eadException(ob ject sender,
ThreadException EventArgs e)
{
DialogResult result = MessageBox.Show (
"Custom Error Message",
"Applicatio n Exception Reported",
MessageBoxButto ns.YesNo,
MessageBoxIcon. Exclamation);
// Exits the program when the user says no.
if (result == DialogResult.No )
Application.Exi t();
}
Here's my _RunWorkerCompl eted() code:
private void backgroundWorke r1_RunWorkerCom pleted(object sender,
RunWorkerComple tedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show ("I handled the error, why does the
ThreadException event still fire?");
}
}
So, here's the question -- why do I get both error messages?