I'm writing a program that uses the .NET performance counter to get CPU, Memory and Network usage for a specific process.
For example, to get the CPU and Memory data for Explorer
, I create performance counters like this:
PerformanceCounter PC = new PerformanceCounter();
PC.CategoryName = "Process";
PC.CounterName = "% Processor Time";
PC.InstanceName = "Explorer";
PerformanceCounter PC = new PerformanceCounter();
PC.CategoryName = "Process";
PC.CounterName = "Working Set - Private";
PC.InstanceName = "Explorer";
Unfortunately, there is no property for the Process categoryName
that allows me to get network usage for that process. I can use the Network Interface categoryName
to get overall network usage on any particular NIC, but cannot isolate it to any given Process.