Why does it not work to use Application.Exit() in C-tor

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

What is the reason that the C-tor must return before the Application.Exit()
work.
So if I just put the Application.Exit() in the Form_Load it works but not
in the C-tor.

//Tony
 
What is the reason that the C-tor must return before the Application.Exit()
work.
So if I just put the Application.Exit() in the Form_Load it works but not
in the C-tor.

//Tony

Application.Exit() just signal all forms to closed itself. If you put
Application.Exit() in the form constructor, the form cannot receive that
message because it does not complete instantiate itself (message pump
have not yet running).
 
What is the reason that the C-tor must return before the Application.Exit()
work.
So if I just put the Application.Exit() in the Form_Load it works but not
in the C-tor.

Try:

Environment.Exit(0);

Arne
 
Back
Top