private bool TryChangeState(AmbientScopeState newState, AmbientScopeState expectedCurrentState) { var previousState = Interlocked.CompareExchange(ref this._state, (int)newState, (int)expectedCurrentState); return(previousState == (int)expectedCurrentState); }
private void ChangeState(AmbientScopeState newState) { this._state = (int)newState; }
private void ChangeState(AmbientScopeState newState, out AmbientScopeState previousState) { previousState = (AmbientScopeState)Interlocked.Exchange(ref this._state, (int)newState); }