在C#中,是否可以将PerformanceCounter放在进程树上

在C#中,是否可以将PerformanceCounter放在进程树上,c#,performancecounter,C#,Performancecounter,我知道如何获取当前进程的性能计数器。但是,当子进程被删除时,有可能从子进程及其所有子进程中获取它们吗 a) 托管代码 b) 本机二进制文件?子进程InstanceNames是父进程的名称,附加了一个#n。这样做可能会有所帮助。以下是所有Chrome进程的处理器时间总和: (new PerformanceCounterCategory("Process")) .GetInstanceNames() .Where(a => a.StartsWith("chrome")) .Select(a =

我知道如何获取当前进程的性能计数器。但是,当子进程被删除时,有可能从子进程及其所有子进程中获取它们吗 a) 托管代码
b) 本机二进制文件?

子进程
InstanceName
s是父进程的名称,附加了一个#n。这样做可能会有所帮助。以下是所有Chrome进程的处理器时间总和:

(new PerformanceCounterCategory("Process"))
.GetInstanceNames()
.Where(a => a.StartsWith("chrome"))
.Select(a => new PerformanceCounter("Process", "% Processor Time", a).NextValue())
.Sum()