Interlocked.Exchange, but not for booleans? Interlocked.Exchange, but not for booleans? multithreading multithreading

Interlocked.Exchange, but not for booleans?


No; use integers instead of booleans.

In principle such a thing could be written (cmpxchg, the underlying processor instruction, can operate on 8, 16, 32, and 64-bit operands on x86, 8, 16, 32, 64, and 128-bit operands on x64), but in practice most APIs stick to pointer and double pointer (32 and 64-bit on x86, 64 and 128-bit on x64) operands, because they're all you really need.