"Atomic Read/Write Using Interlocked"

private static long sharedState;
public static long SharedState {
	get {
		return Interlocked.Read(ref sharedState);
	}
	set {
		Interlocked.Exchange(ref sharedState, value);
	}
}


Code snippet taken from "Common Multithreading Mistakes in C# - III: Unsafe Assumptions".