Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function atomically exchanges a pair of 32-bit values.
Syntax
LONG InterlockedExchange( LPLONG Target, LONG Value ); |
Parameters
- Target
-
[in] Pointer to the LONGvalue to exchange. The function sets this LONGvalue to Value, and returns its prior value.
- Value
-
[in] Specifies a new value for the LONGvalue pointed to by Target.
Return Value
The prior value of the LONGvalue pointed to by Targetindicates success.
Remarks
The functions InterlockedExchange, InterlockedCompareExchange, InterlockedDecrement, InterlockedExchangeAdd, and InterlockedIncrementprovide a simple mechanism for synchronizing access to a variable that is shared by multiple threads. The threads of different processes can use this mechanism, if the variable is in shared memory.
The variable pointed to by the Targetparameter must be aligned on a 32-bit boundary; otherwise, this function will fail.
Requirements
Header | winbase.h |
Library | coredll.lib |
Windows Embedded CE | Windows CE 1.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |