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
 

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