This documentation is archived and is not being maintained.

PerformanceCounter.RawValue Property

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

[Visual Basic]
Public Property RawValue As Long
public long RawValue {get; set;}
public: __property __int64 get_RawValue();
public: __property void set_RawValue(__int64);
public function get RawValue() : long;
public function set RawValue(long);

Property Value

The raw value of the counter.


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


The instance is not correctly associated with a performance counter.

Win32Exception An error occurred when accessing a system API.


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.


Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

PerformanceCounter Class | PerformanceCounter Members | System.Diagnostics Namespace