Shutting down program from a constructor

aewarnick

Senior Contributor
Joined
Jan 29, 2003
Messages
1,031
How can I shut my program down while loading? I tried

this.Close();
and
Application.Exit();

but, they did nothing.
 
A constructor isn't a very good place to put something like this. If you're instantiating a class, it implies that you want to go all the way through instantiating it.

You can probably close the application in the form's Load event, which will be called just after the constructor executes. Failing that, close the application in your Main function, before the form even gets instantiated.
 
Back
Top