我使用的是System.Data PerfomanceCounter
類,並且我發現了一些非常具體的如何檢索磁盤空間或CPU使用情況的示例。C#PerformanceCounter可能的參數列表?
但是我無法找到的文檔上的可能值:
PerfomanceCounter.CategoryName
PerformanceCounter.CounterName
PerformanceCounter.InstanceName
I can see from the class the different parameters我可以傳遞給構造函數,但即使要the page for say CategoryName不給我提供值的列表。
任何人都可以提供和建議如何找到這些可用的值?
謝謝! (有太多的張貼)
PerformanceCounterCategory[] categories = PerformanceCounterCategory.GetCategories();
foreach(var category in categories)
{
string[] instanceNames = category.GetInstanceNames();
foreach(string instanceName in instanceNames)
PerformanceCounter[] counters = category.GetCounters(instanceName);
}
哇,有很多類別,我想我需要重新說一下我的問題。它也不斷崩潰,說當前的上下文中不存在像DllHost/1這樣的東西。所以我還沒有找到完整的列表! –
請注意,您可以對類別數組使用標準Linq查詢進行篩選。 –
任何人都可以在網上發佈清單嗎? –