Updated: May 2011
Writes a value to a field immediately, so that the value is visible to all processors in the computer.
Assembly: mscorlib (in mscorlib.dll)
Public Shared Sub VolatileWrite ( _ ByRef address As Byte, _ value As Byte _ )
public static void VolatileWrite( ref byte address, byte value )
public: static void VolatileWrite( unsigned char% address, unsigned char value )
static member VolatileWrite : address:byte byref * value:byte -> unit
Parameters
- address
- Type: System.Byte%
The field to which the value is to be written.
- value
- Type: System.Byte
The value to be written.
VolatileRead and VolatileWrite are for special cases of synchronization. Under normal circumstances, the C# lock statement, the Visual Basic SyncLock statement, and the Monitor class provide easier alternatives.
On a multiprocessor system, VolatileWrite ensures that a value written to a memory location is immediately visible to all processors. This might require flushing processor caches.
Even on a uniprocessor system, VolatileRead and VolatileWrite ensure that a value is read or written to memory, and not cached (for example, in a processor register). Thus, you can use them to synchronize access to a field that can be updated by another thread, or by hardware.
Calling this method affects only a single memory access. To provide effective synchronization for a field, all access to the field must use VolatileRead or VolatileWrite.
.NET Framework
Supported in: 4, 3.5, 3.0, 2.0, 1.1.NET Framework Client Profile
Supported in: 4, 3.5 SP1Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Reference
|
Date |
History |
Reason |
|---|---|---|
|
May 2011 |
Removed erroneous statement about C#. |
Content bug fix. |