Scott,
As Peter suggests.
If another app terminates your app. It is terminated immediately without any
chance for any more code to run.
I vaguely remember (very vaguely) there was a Win32 "callback" that your app
could use to allow it a "last chance" to avoid being terminated, however I
don't have a reference handy.
--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley -
http://www.tsbradley.net
| Yes, it is a windows form. How about if the process is killed? I really
| need the code to run every time it exits. No matter how it exits.
|
| message | > Scott,
| > Is this a Windows Forms app?
| >
| > If so:
| >
| > Have you looked at using the Application.ApplicationExit event?
| >
| > In addition to the Application.ThreadException &
| > AppDomain.UnhandledException events?
| >
| > The ApplicationExit event should let you know when your app is exiting
| > normally, while the ThreadException will prevent exceptions during
"window
| > event processing" from killing your app, and UnhandledException will let
| > you
| > know when your app is not exiting normally.
| >
| > --
| > Hope this helps
| > Jay [MVP - Outlook]
| > T.S. Bradley -
http://www.tsbradley.net
| >
| >
| > | > |I have a procedure in my Dispose method that records my application was
| > | closed in a database. However, when I kill a process or an unhandled
| > | exception occurs this does not seem to run. Is there some code that
is
| > | GUARANTEED to run EVERY time the code exits? I don't mind if it runs
| > during
| > | garbage collection or whatever. I just need it to run to log the
| > | application closing for compliance reasons.
| > |
| > | Thanks in advance
| > | Scott
| > |
| >
| >
|