Interlocked.Exchange(Of T) Method (T%, T)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Sets a variable of the specified type T to a specified value and returns the original value, as an atomic operation.
Assembly: mscorlib (in mscorlib.dll)
'Declaration Public Shared Function Exchange(Of T As Class) ( _ ByRef location1 As T, _ value As T _ ) As T
Type Parameters
- T
The type to be used for location1 and value. This type must be a reference type.
Parameters
- location1
- Type:
T
%
The variable to set to the specified value. This is a reference parameter (ref in C#, ByRef in Visual Basic).
- value
- Type: T
The value to which the location1 parameter is set.
Return Value
Type: TThe original value of location1.
| Exception | Condition |
|---|---|
| NullReferenceException | The address of location1 is a null pointer. |
Show: