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.
A version of this page is also available for
4/8/2010

Interlocked functions synchronize access to a variable that is shared by multiple threads.

Their purpose is to prevent a thread from being preempted while it is incrementing or checking a variable.

The threads of different processes can use these functions as long as their variables share memory.

The following table describes the interlocked functions that Windows Mobile supports.

Function Description

InterlockedIncrement

Increments a shared variable, and checks the resulting value.

InterlockedDecrement

Decrements a shared variable, and checks the resulting value.

InterlockedExchange

Exchanges the values of specified variables.

InterlockedTestExchange

Exchanges the values of specified variables if one variable is set to a specified value.

InterlockedCompareExchange

Compares the values of specified values and exchange the values based on the outcome.

InterlockedCompareExchangePointer

Performs an atomic addition of an increment value to an addend value.

InterlockedExchangePointer

Performs an atomic comparison of specified values, and exchanges the values, based on the outcome of the comparison.

InterlockedExchangeAdd

Atomically exchanges a pair of values.

See Also