I wish to atomically increment a static variable and simultaneously assign the new value to an instance field in a lock-free manner. The objective is for each object to get a un
You only need to do this:
orderingId = Interlocked.Increment(ref currentOrderingId);
There's no way that two threads could then receive the same value, so it is threadsafe.