By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,635 Members | 1,781 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,635 IT Pros & Developers. It's quick & easy.

Killing the c# executable

P: n/a
How can i control my program when someone kill it's process from the
taskmanager
my dispose script is working well if i close the program manually but
if i kill it from taskmanager its not working
how can i fix it
my dispose script is 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);

}

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Dakkar,

What are you trying to achieve by doing this?

If you close your program from the task manager, it kills the process,
much like calling Kill on the Process class. This forces abnormal process
termination, just clearing the process out. It doesn't send a message to
the app to shut down, it just stops it, immediately.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dakkar" <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote in message
news:42********@127.0.0.1...
How can i control my program when someone kill it's process from the
taskmanager
my dispose script is working well if i close the program manually but
if i kill it from taskmanager its not working
how can i fix it
my dispose script is 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);

}

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 16 '05 #2

P: n/a
Killing a process is just that, it doesn't allow the process to run any
longer. So I don't believe you can get your destroy to run if someone kills
the process. What you can try however, is maybe move the code below into a
service that runs as the system, or launch the application that runs the
code below as a different user.

--
Thanks
Wayne Sepega
Jacksonville, Fl
"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

"Dakkar" <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote in message
news:42********@127.0.0.1...
How can i control my program when someone kill it's process from the
taskmanager
my dispose script is working well if i close the program manually but
if i kill it from taskmanager its not working
how can i fix it
my dispose script is 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);

}

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 16 '05 #3

P: n/a
so if i cant do something like this are there anyway to make my
process invisible
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 16 '05 #4

P: n/a
Make it a service. Then the OS makes sure that you're notifed when someone
wants to shut you down.

"Dakkar" <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote in message
news:42********@127.0.0.1...
so if i cant do something like this are there anyway to make my
process invisible
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 16 '05 #5

P: n/a
So how can i make my program as a service
Sean Hedermanwrote: Make it a service. Then the OS makes sure that you're notifed when
someone wants to shut you down.

"Dakkar" <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote in message news:42********@127.0.0.1...
so if i cant do something like this are there anyway to make my
process invisible
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com[/quote:2361bec79e]

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 16 '05 #6

P: n/a
File new Project --> Windows Service

I would suggest however, that you do some research on services first. Try
www.codeproject.com or the MDSN help file.

--
Thanks
Wayne Sepega
Jacksonville, Fl
"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

"Dakkar" <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote in message
news:42********@127.0.0.1...
So how can i make my program as a service
Sean Hedermanwrote:

Make it a service. Then the OS makes sure that you're notifed when
someone
wants to shut you down.

"Dakkar" <da****@sylveria.gen-dot-tr.no-spam.invalid> wrote in

message
news:42********@127.0.0.1...
so if i cant do something like this are there anyway to make my
process invisible
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com[/quote:2361bec79e]

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.