DotNext by Roman Sakno

<PackageReference Include="DotNext" Version="1.0.0" />

 AtomicEnum

public static class AtomicEnum
Provides basic atomic operations for arbitrary enum type.
using System; using System.Runtime.CompilerServices; namespace DotNext.Threading { public static class AtomicEnum { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static E VolatileRead<E>(ref E value) where E : struct, Enum { return Atomic.Read(ref value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void VolatileWrite<E>(ref E value, E newValue) where E : struct, Enum { Atomic.Write(ref value, newValue); } } }