Home All Groups Group Topic Archive Search About

Kill a dead process

Author
6 Feb 2006 9:31 PM
Luca B
Hi all, I hope someone has an answer for this...
I have a Windows service that creates several instances of
Access.Application connected to a ADP project. I want my service to check the
activity of these instances and kill them as needed.
I managed to get the Process object related to each instance and now I want
to use a PerformanceCounter to check the process CPU usage, with the
following code

PerformanceCounter pc=new PerformanceCounter("Process", "% Processor Time");
pc.InstanceName = accessprocess.ProcessName;
pc.NextValue();
if (pc.NextValue() > 90)
    accessprocess.Kill();

Only problem is that each instance has the same ProcessName (namely,
MSACCESS)!!!
How can I retrieve a valid InstanceName for each instance?
Or, how can I accomplish this task in a different way?

Thanks in advance!

AddThis Social Bookmark Button