public bool DecrementWithSetFlag()
{
while (true)
{
var v = _value;
if (v < 2)
throw new InvalidOperationException("Already Zero");
var vNew = ((v - 2) & 0x7FFFFFFE) + 1;
if (Interlocked.CompareExchange(ref _value, vNew, v) == v)
return vNew == 1;
}
}
}