internal static int NextVariableIndex() { int index = Interlocked.Increment(ref nextIndex); if (index < 0) { Interlocked.Decrement(ref nextIndex); throw new InvalidOperationException("too many thread-local indexed variables"); } return index; }