How to: Retrieve Raw Performance Counter Values
You retrieve raw performance counter values by retrieving the current value of the RawValue property on the PerformanceCounter class.
To retrieve a counter's raw value
Create a PerformanceCounter instance and configure it to interact with the desired category and counter. For more information, see How to: Create PerformanceCounter Component Instances or How to: Configure PerformanceCounter Component Instances.
Retrieve the current value of the RawValue property.
The following example illustrates how to use the RawValue property to retrieve the current value of the % Processor Time counter:
Dim MyCounter As New PerformanceCounter() MyCounter.CategoryName = "Processor" MyCounter.CounterName = "% Processor Time" MyCounter.InstanceName = "_Total" Dim raw As Int64 raw = MyCounter.RawValue
System.Diagnostics.PerformanceCounter myCounter = new System.Diagnostics.PerformanceCounter(); myCounter.CategoryName = "Processor"; myCounter.CounterName = "% Processor Time"; myCounter.InstanceName = "_Total"; long raw = myCounter.RawValue;
See Also
Tasks
How to: Retrieve Calculated Performance Counter Values
How to: Retrieve Performance Counter Samples
How to: Retrieve Lists of Counters and Categories