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.
 
Back
Top