Form Termination

  • Thread starter Thread starter Nadav
  • Start date Start date
N

Nadav

Hi,

I am writing Forms application, at certain situations I need to prematurely
close it, e.g. upon invalid initialization the App should be closed, using
....Form.Close from the forms constructor doesn't help, I wonder... Is there
an equivalent to the C++ PostQuitMessage(0) in C#? What is it?

ThanX
Nadav.
 
Hi Nadav,

Application.Exit() terminates the application.

One suggestion to handle the scenario you describe is to throw an exception
in
your form's constructor, then trap that exception in your app's
Main() entry point method.
If an exception is thrown, do not call Application.Run() to run the
message loop and just return from Main() without loading the form.

Regards,
Aravind C
 

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