Application.Exit() doesn't react

  • Thread starter Thread starter Jesper Denmark
  • Start date Start date
J

Jesper Denmark

Hi,

After a given exception I would like to terminate the
program. I've been told that Application.Exit() should do
the trick, but I cant seem to make it work at all. It
compiles fine. But it doesn't seem to do anything - the
program just continues after calling the function. Should
it be in a certain scope or called via the object that
was given as an argument to Application.Run?

Please help.
Jesper.
 
Hi Jesper,

In the MSDN is clearly stated that a call to this method does not force the
application to exit, try to use a Application.DoEvents() after it as it will
process the messages in the queue.


Cheers,
 
Jesper,

Are you exiting whatever event handler you are in after you make the
call? If you are on the UI thread and make the call, then you should return
from your method and then let the main message loop process the WM_QUIT
message (which is what is sent to your app when you call the Quit method).
If you keep performing processing, then the loop has to wait until your
processing is done to process the event.

Hope this helps.
 
Back
Top