Click or drag to resize
InterlockedCompareExchange Method (IntPtr, IntPtr, IntPtr)
Compares two platform-specific handles or pointers for equality and, if they are equal, replaces one of them.

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public static IntPtr CompareExchange(
	ref IntPtr location1,
	IntPtr value,
	IntPtr comparand
)

Parameters

location1
Type: SystemIntPtr
The destination IntPtr, whose value is compared with the value of comparand and possibly replaced by value.
value
Type: SystemIntPtr
The IntPtr that replaces the destination value if the comparison results in equality.
comparand
Type: SystemIntPtr
The IntPtr that is compared to the value at location1.

Return Value

Type: IntPtr
The original value in location1.
Exceptions
ExceptionCondition
NullReferenceExceptionThe address of location1 is a null pointer.
See Also