Shutting down program from a constructor

aewarnick

Well-known member
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 isnt a very good place to put something like this. If youre instantiating a class, it implies that you want to go all the way through instantiating it.

You can probably close the application in the forms 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