Hi, thank you for your attention, first.
Now, I need to get an exact CPU usage of certain process.
I googled all day long looking for this stuff
and I got this codes.
while (true)
{
using (PerformanceCounter pcProcess = new PerformanceCounter("Process", "% Processor Time", _testProcess.ProcessName))
{
pcProcess.NextValue();
System.Threading.Thread.Sleep(1000);
Console.WriteLine("Process:{0} CPU% {1}", _testProcess.ProcessName, pcProcess.NextValue());
}
}
It gives some value but unfortunately it is little bigger than it is supposed to be when it is compared to the one in the Task Manager.
When I try to get the entire CPU usage with the same way, it seems to be right
but I can't figure out why it is so much bigger than it should be.
Sometimes it is bigger than the entire CPU usage.
I need some help over here.
If I can, I want to give someone who solves this problem something.
Thanks and regards.
Andrew.