471,627 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Exception handling with Modeless dialogs

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

Jan 4 '06 #1
2 1497
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"john doe" <sl********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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

Jan 4 '06 #2
Thank you Nicholas, as ever a reliable answer

Jan 11 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.