This documentation is archived and is not being maintained.

Retrieving 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

  1. Create a PerformanceCounter instance and configure it to interact with the desired category and counter. For more information, see Creating PerformanceCounter Component Instances or Configuring PerformanceCounter Component Instances.
  2. 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:

    ' Visual Basic
    Dim MyCounter As New PerformanceCounter()
    MyCounter.CategoryName = "Processor"
    MyCounter.CounterName = "% Processor Time"
    MyCounter.InstanceName = "_Total"
    Dim raw As Int64
    raw = MyCounter.RawValue
    // C#
    System.Diagnostics.PerformanceCounter myCounter = 
       new System.Diagnostics.PerformanceCounter();
    myCounter.CategoryName = "Processor";
    myCounter.CounterName = "% Processor Time";
    myCounter.InstanceName = "_Total";
    long raw = myCounter.RawValue;

See Also

Performance Counter Value Retrieval | Retrieving Calculated Performance Counter Values | Retrieving Performance Counter Samples | Retrieving Lists of Counters and Categories