Task manager has two modes of shutting an application down: End Task, which
sends a WM_QUIT message to the foreground window, and End Process which
calls TerminateProcess for the process.
TerminateProcess is a nasty way to shut down an app, basically all the
threads are stopped in their tracks, the DLLs unloaded and the process
closed. Your application does not have the opportunity to handle this
scenario.
From MSDN:
Terminating a process does not cause child processes to be terminated.
Neither the process nor any DLLs attached to the process are notified that
the process is terminating. A process cannot prevent itself from being
terminated.
So basically, since you appear to want to close child processes in your
application when the process is terminated, you can't. You could have your
application act as a remoting host, and if the child processes can't connect
every so often they close themselves down.
"Dakkar" <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote in message
news:42********@127.0.0.1...
I have a program with windows forms and after execution of my program
im making it invisible for working background progress and i have a
dispose function like this
protected override void Dispose(bool Disposing)
{
if (Disposing)
{
if (components != null)
{
components.Dispose();
}
}
Process[] procuo = Process.GetProcesses();
for (int i = 0; i < procuo.Length; i++)
{
if(procuo[i].ProcessName.Equals("client"))
{
procuo[i].Kill();
}
}
base.Dispose(true);
}
if i close the program normally(pressing X before it become invisible)
its normally closing the client.exe but if i kill it from task manager
its not closing the client.exe how can i do that?
Thanks
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com