Can an application sense that it's terminating?

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

Guest

If a Windows User decides to kill a process or a separate Windows app calls Process.Kill(), is there any way that the process being killed can see what's going on before it dies? I have a Windows Service that uses some third party dlls which are a bit messy. If the application is improperly closed, all kinds of things start to go wrong, so I want to catch the Kil
command and clean up before dying

It's very likely that what I'm asking isn't possible, but if so, are there any strategies to mimic this behavior? Like a separate process can somehow trigger some flags that the other application checks???
 
AFAIK app has no chance to detect if it is being killed.

Imagine if there would be an event on process kill - the applications can
become immortal

Jerry said:
If a Windows User decides to kill a process or a separate Windows app
calls Process.Kill(), is there any way that the process being killed can see
what's going on before it dies? I have a Windows Service that uses some
third party dlls which are a bit messy. If the application is improperly
closed, all kinds of things start to go wrong, so I want to catch the Kill
command and clean up before dying.

It's very likely that what I'm asking isn't possible, but if so, are there
any strategies to mimic this behavior? Like a separate process can somehow
trigger some flags that the other application checks???
 
Yep, that's kinda what I was afraid of. Maybe I can solve this problem using Remoting. For instance, the process I want to kill has a remote object exposed that can trigger an event, allowing my process to die gracefully. Thoughts

JER
 
If you are looking to ensure that a program cannot be shut down, you have to
create two processes:

....Since you can't kill two processes at the same time via TaskManager...

a) checks to see if b) is still running -- if b) dies, it restarts it, and
viceversa for b)...

Hope that helps.



Jerry said:
Yep, that's kinda what I was afraid of. Maybe I can solve this problem
using Remoting. For instance, the process I want to kill has a remote
object exposed that can trigger an event, allowing my process to die
gracefully. Thoughts?
 
Back
Top