Max Fate

Max Fate

  • NA
  • 1
  • 0

Unhandled exceptions

Jan 28 2008 1:36 PM
Some problems with unhandled exceptions (to report about them). I'm creating small bug reporter...

Well, we need small example to set issue.

Let's have a Windows Application with a form and 3 buttons on it. Their click handlers are

private void button1_Click(object sender, EventArgs e)
{
  ThrowException();
}

private void button2_Click(object sender, EventArgs e)
{
  Thread t = new Thread(ThrowException);
  t.Start();
}

private void button3_Click(object sender, EventArgs e)
{
  (new VoidHandler(ThrowException)).BeginInvoke(null, null);
}

private void ThrowException()
{
  throw new Exception("Test");
}

1. On 1st button click I can handle Application.ThreadException, show "I'm sorry" dialog, prepare a report, and continue execution.
2. On 2nd button click I can handle AppDomain.UnhandledException, show dialog, prepare report, but unable to continue execution.

Question 1. How can I rid of the standart "Close dialog" and continue running in that case?

3. There is no unhandled exception dialog on 3rd button click.

Question 2. Why the Exception disappeared like it was not thrown? How can I intercept such unhandled exceptions?