public bool CompareAndSet(int expect, int update) { int rc = Interlocked.CompareExchange(ref value, update, expect); return rc == expect; } }