private void SwitchState(ICircuitBreakerState from, ICircuitBreakerState to) { if (Interlocked.CompareExchange(ref _currentState, to, from) == from) { to.Enter(); } }
private bool TryToTrip(ICircuitBreakerState from, ICircuitBreakerState to) { if (Interlocked.CompareExchange(ref _currentState, to, from) == from) { to.Enter(); return(true); } return(false); }