使用 Process PerformanceCounters,我如何知道实例与哪个进程关联?
查询“进程”性能计数器类别的实例时,可能存在同名进程的多个实例。
例如这段代码:
var cat = new PerformanceCounterCategory("Process");
var names = cat.GetInstanceNames();
foreach (var name in names)
Console.WriteLine(name);
可能会打印这些结果: ... 探索 我探索#1 我探索#2 我探索#3 ...
我如何知道每个计数器实例对应哪个进程?
When querying instances for the the "Process" performance counter category there might be multiple instances of of a process with the same name.
For example this code:
var cat = new PerformanceCounterCategory("Process");
var names = cat.GetInstanceNames();
foreach (var name in names)
Console.WriteLine(name);
Might print these results:
...
iexplore
iexplore#1
iexplore#2
iexplore#3
...
How do I know which process each of these counter instances corresponds to?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“进程”类别中有一个名为“ID Process”的 PerformanceCounter,它将返回性能计数器实例对应的进程的 pid。
这将打印:
There is a PerformanceCounter named "ID Process" in the "Process" category that will return the pid of the process that the performance counter instance corresponds to.
This will print: