Terminating the main window

  • Thread starter Thread starter Michel Racicot
  • Start date Start date
M

Michel Racicot

Within a catch statement located in my main window's constructor, I want my
application to terminate.

I've tried doing this:
try

{

// Some code that raise an exception...

}

catch (Exception eError)

{

MessageBox.Show(eError.Message);

Application.Exit();

}



But my application still continues running... How can I stop it?



Thank you
 
Hi Michael,

Just let the exception go. Catch it in the main method level and do *return*
from the exception's catch block. As long as the Application.Run is not
called the GUI is not running.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top