Exception handling with Modeless dialogs

  • Thread starter Thread starter john doe
  • Start date Start date
J

john doe

I have the following code:

private void LaunchForm()
{
Form1 form1 = new Form1();
form1.Show();
}

My question is, where does form1 "go" once the method has exited?
Specifically, I'm interested in not having to put try/catch blocks
inside every method of my form, but rather have one central place that
all exceptions are caught.

Putting the try/catch block inside the LaunchForm() method above
obviously will not catch any exceptions on the form, as the method
exits.

Any suggestions?

Thanks
 
John,

You want the ThreadException event on the Application class. This will
only work in Windows Forms, and only handle unhandled exceptions that occur
on the UI thread. Any other exceptions on other threads will not be
handled.

Hope this helps.
 
Back
Top