G
Guest
I have a problem that relates to running "cleanup" code when an application
is forcibly ended using the "End Process" of "Task Manager" (Please note that
this is very different from "End Task" since end task sends a message to the
application, requesting it to close)
My real problem is that our application makes entries into a database when
the application starts, and then corresponding entries when the application
closes ("cleanup"). This application is run in a terminal session, and
disconnected sessions are forced closed after a certain amount of time has
passed, effectively ending all the processes of the terminal session. This is
equivalent to "End Process" of the application using Task Manager.
I'm unable to run any code when this happens, the code does not return after
the Application.Run(...) statement, so putting a try-catch-finally around it
doesn't work because it isn't run.
Adding event handlers to AppDomain.ProcessExit doesn't work, nor does adding
a MessageFilter to the Application's message loop.
How do I get code to run under these circumstances ?
is forcibly ended using the "End Process" of "Task Manager" (Please note that
this is very different from "End Task" since end task sends a message to the
application, requesting it to close)
My real problem is that our application makes entries into a database when
the application starts, and then corresponding entries when the application
closes ("cleanup"). This application is run in a terminal session, and
disconnected sessions are forced closed after a certain amount of time has
passed, effectively ending all the processes of the terminal session. This is
equivalent to "End Process" of the application using Task Manager.
I'm unable to run any code when this happens, the code does not return after
the Application.Run(...) statement, so putting a try-catch-finally around it
doesn't work because it isn't run.
Adding event handlers to AppDomain.ProcessExit doesn't work, nor does adding
a MessageFilter to the Application's message loop.
How do I get code to run under these circumstances ?