I think this applies to features like Interlocked.CompareExchange.
This method can be used, for example, to atomically update a double:
static void Add(ref double field, double amount)
{
double before, after;
do
{
before = field;
after = before + amount;
}
while (Interlocked.CompareExchange(ref field, after, before) != before);
}
source
share