Example #1
0
        private void SwitchToState(ICircuitState state)
        {
            var currentState = _currentState;

            if (currentState != state &&
                Interlocked.CompareExchange(ref _currentState, state, currentState) == currentState)
            {
                state.Entered();
                try
                {
                    _onStateChange?.Invoke(this, state.Status);
                }
                catch (Exception)
                { }
            }
        }