.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Enumerating the PerformanceCounterCategory class
 

Enumerating the PerformanceCounterCategory class

The following methods fails saying it cannot convert from type System.Collections.DcitionaryEntry to type System.Diagnostics.InstanceDataCollection. I've tried type casting, but to no avail. If I iterate through the DemoCollection DictionaryEntry objects, I haven't found a way to get at the InstanceDataCollection that should be hidden somewhere in this object. How can I fix this?

Code Snippet

static void ReadPerformanceCounterCategories()

{

//ReadCategory reads all the counter and performance object instace data associated with this category

PerformanceCounterCategory DemoCounterCategory = new PerformanceCounterCategory(".NET CLR Memory");

InstanceDataCollectionCollection DemoCollection = DemoCounterCategory.ReadCategory();

//IDictionaryEnumerator enumer = DemoCollection.GetEnumerator();

Debug.Assert(DemoCollection != null, "DemoCollection is null");

foreach (InstanceDataCollection thisCollection in DemoCollection)

{

Console.WriteLine(thisCollection.CounterName);

}

}

P.Brian.Mackey

Well, this example covers it (though it is much more elaboratethan I'd hoped) http://msdn2.microsoft.com/en-us/library/system.diagnostics.tracesource.aspx

I believe there is a simpler implementationfor a single PerformanceCounterCategory that has been hard coded, as is the case here;especially since the code I posted came straight out of a Microsoft book (ISBN: 0-7356-2277-9) pg 604.

P.Brian.Mackey

Well, this example covers it (though it is much more elaboratethan I'd hoped) http://msdn2.microsoft.com/en-us/library/system.diagnostics.tracesource.aspx

I believe there is a simpler implementationfor a single PerformanceCounterCategory that has been hard coded, as is the case here;especially since the code I posted came straight out of a Microsoft book (ISBN: 0-7356-2277-9) pg 604.

P.Brian.Mackey

You can use google to search for other answers

Custom Search

More Threads

• How to join 2 strings?
• How to Get list of local users using c#.Net
• Where to store the users?
• How create nested namespace?
• .Net Sample will not Register!
• Gridview need help
• Using a IEEE488 Class with multiple classes
• C# How to Read Byte-to-Byte from Serial Port?
• Obtaining file's owner's SID (fast)
• Fail to generate SQL commands when using Data Adapter Configuration Wizard