public void FreeBuildState() { bool b = Interlocked.CompareExchange(ref isProfilingBuildTime, 0, 1) == 1; //! The free-er should be holding the lock. Debug.Assert(b); }