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
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;
Performance Counter Value Retrieval | Retrieving a Sample of Performance Counter Values | Creating PerformanceCounter Components | Configuring PerformanceCounter Components