Mono Class Library: System.Threading.Interlocked Overview | Members

System.Threading.Interlocked.CompareExchange Method

Compares two object variables for equality and stores a specified object if they are equal. [Edit]

[System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)]
public static object CompareExchange (ref object location1, object value, object comparand)

Parameters

location1
A object reference that is set to value if the object to which it refers is equal to comparand. [Edit]
value
The reference that will replace the value of location1 if location1 and comparand are equal. [Edit]
comparand
An object to be compared to that referred to by location1. [Edit]

Returns

A object containing the original value of location1. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionThe address of location1 is null . [Edit]

Remarks

The compare and store operations are performed as an atomic operation. [Edit]

Requirements

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0