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

System.Threading.Interlocked.CompareExchange Method

Compares two int values for equality and stores a specified value if they are equal. [Edit]

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

Parameters

location1
A int reference whose value is updated with value if the original value of location1 is equal to comparand. [Edit]
value
A int whose value will replace the value of location1 if location1 and comparand are equal. [Edit]
comparand
A int to be compared to location1. [Edit]

Returns

The original value of location1. [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