PerformanceCounter.NextValue Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Obtains a counter sample and returns the calculated value for it.

Namespace:   System.Diagnostics
Assembly:  System (in System.dll)

member NextValue : unit -> float32

Return Value

Type: System.Single

The next calculated value that the system obtains for this counter.

Exception Condition

The instance is not correctly associated with a performance counter.


An error occurred when accessing a system API.


The platform is Windows 98 or Windows Millennium Edition (Me), which does not support performance counters.


Code that is executing without administrative privileges attempted to read a performance counter.


If the calculated value of a counter depends on two counter reads, the first read operation returns 0.0. Resetting the performance counter properties to specify a different counter is equivalent to creating a new performance counter, and the first read operation using the new properties returns 0.0. The recommended delay time between calls to the NextValue method is one second, to allow the counter to perform the next incremental read.


To read performance counters, you must have administrative privileges. In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that accesses performance counters, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator.

The following code example creates an ElapsedTime counter and uses the NextValue method to display the counter's values over a time period.

No code example is currently available or this language may not be supported.


for reading the performance counter category. Associated enumeration: PerformanceCounterPermissionAccess.Read.

.NET Framework
Available since 1.1
Return to top