Application.ApplicationExit Event not firing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have added an event handler to my application with the following code

Application.ApplicationExit +=new EventHandler(Application_ApplicationExit);

The event handler Application_ApplicationExit is called when
Application.Exit() is called, however if the application is terminated by
shutting down windows this event is not called. Is there any way to catch it
? I need to save state before the application terminates.

Thanks

Ian
 
AxiomIan said:
The event handler Application_ApplicationExit is called when
Application.Exit() is called, however if the application is terminated by
shutting down windows this event is not called.

You may want to listen for 'WM_ENDSESSION' and/or 'WM_QUERYENDSESSION' in a
form's 'WndProc' to get a notification if Windows is shutting down.
 
Back
Top