Export (0) Print
Expand All

PerformanceCounter.RawValue Property

Gets or sets the raw, or uncalculated, value of this counter.

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

public long RawValue { get; set; }
/** @property */
public long get_RawValue ()

/** @property */
public void set_RawValue (long value)

public function get RawValue () : long

public function set RawValue (value : long)

Property Value

The raw value of the counter.

Exception typeCondition

InvalidOperationException

You are trying to set the counter's raw value, but the counter is read-only.

-or-

The instance is not correctly associated with a performance counter.

-or-

The InstanceLifetime property is set to Process when using global shared memory.

Win32Exception

An error occurred when accessing a system API.

PlatformNotSupportedException

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

If the counter type is a 32-bit size and you attempt to set this property to a value that is too large to fit, the property truncates the value to 32 bits. When reading custom counters on the local computer, using the RawValue property rather than a calculated value can produce significantly better performance in scenarios where the raw value is sufficient.

If the counter that you are reading is read-only, getting the RawValue property samples the counter at the time that the property is called. This action is equivalent to making an initial call to the NextSample method. If you subsequently call NextSample, you can perform calculations on the values that both calls returned.

Because system counters are read-only, you can get but not set their raw values.

NoteNote

The Increment, IncrementBy, and Decrement methods use interlocks to update the counter value. This helps keep the counter value accurate in multithreaded or multiprocess scenarios, but also results in a performance penalty. If you do not need the accuracy that interlocked operations provide, you can update the RawValue property directly for up to a 5 times performance improvement. However, in multithreaded scenarios, some updates to the counter value might be ignored, resulting in inaccurate data.

NoteNote

If the value for the InstanceLifetime property is Process and the performance counter category was created with .NET Framework version 1.0 or 1.1, an InvalidOperationException is thrown. Performance counter categories created with earlier versions use global shared memory, and the value for InstanceLifetime must be Global. If the category is not used by applications running on versions 1.0 or 1.1 of the .NET Framework, delete and recreate the category.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft