NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Retrieving Calculated Performance Counter Values

You retrieve calculated performance counter values by calling the NextValue method on the current counter. The counter’s calculated value at the instant that the method executes is calculated and returned to you. Calling NextValue a second time will retrieve a different value, because the calculated value changes as the counter increments.

Note   To retrieve more complex views of the data in the counter, you can use samples to retrieve static snapshots of counter data at two points in time, and perform comparisons on those returns. For instructions on retrieving a sample, see Retrieving a Sample of Performance Counter Values.

To retrieve a counter’s calculated value

  1. Create a PerformanceCounter instance and configure it to interact with the desired category and counter. For details, see Creating PerformanceCounter Components  or Configuring PerformanceCounter Components .
  2. Call the NextValue method.

    The following example illustrates how to use the NextValue property to retrieve the current value of the BookOrders counter:

    [Visual Basic]
    Dim MyCtr as New PerformanceCounter
    MyCtr.Category= "Orders"
    MyCtr.Counter= "Total"
    Dim raw as int64
    Raw = MyCtr.NextValue
    [C#]
    PerformanceCounter MyCtr = new PerformanceCounter();
    MyCtr.Category= "Orders";
    MyCtr.Counter= "Total";
    Int64 Raw = MyCtr.NextValue;

See Also

Performance Counter Value Retrieval | Retrieving a Sample of Performance Counter Values | Creating PerformanceCounter Components  | Configuring PerformanceCounter Components