C# PerformanceCounter 可能的参数列表?

标签 c# parameters performancecounter

我正在使用 System.Data PerfomanceCounter 类,并且我找到了一些关于如何检索磁盘空间或 CPU 使用率的非常具体的示例。

但是我找不到关于以下可能值的文档:

PerfomanceCounter.CategoryName
PerformanceCounter.CounterName
PerformanceCounter.InstanceName

I can see from the class the different parameters我可以传递给构造函数,但甚至会转到 the page for say CategoryName没有给我可用值的列表。

任何人都可以就如何找到这些可用值提供建议吗?

谢谢!

最佳答案

那些可以从PerformanceCounterCategory获得类:

PerformanceCounterCategory[] categories = PerformanceCounterCategory.GetCategories();
foreach(var category in categories)
{
    string[] instanceNames = category.GetInstanceNames();
    foreach(string instanceName in instanceNames)
        PerformanceCounter[] counters = category.GetCounters(instanceName);
}

关于C# PerformanceCounter 可能的参数列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23366831/

相关文章:

c# - 如何从 Foreach 循环中的 IList 更新记录?

c# - Task.Run() 不异步运行

c# - 有没有比Environment.StackTrace更简洁的方法来获取调用堆栈信息?

Javascript 函数练习 - ""符号

c# - 为什么调用 PerformanceCounter 很慢?

c# - Python 等同于 C# 的 .Select?

java - 为什么在 Java (BlueJ) 中使用 ArrayList 作为构造函数参数?

c++ - C++ 构造函数中的字符串作为参数

neo4j - 基于数据neo4j执行操作

c# - C# 中的性能计数器不准确