示例#1
0
        private void UpdateConnectionState(CGConnectionState connectionState)
        {
            var i = 0;

            while (true)
            {
                var oldState = _connectionState;
                var s        = (CGConnectionState)Interlocked.CompareExchange(ref _connectionState, (int)connectionState, oldState);
                if (s == connectionState)
                {
                    break;
                }

                _configuration.Logger.Warn($"Eternal rush detected: {connectionState}");
                i++;
            }

            if (i > 0)
            {
                _configuration.Logger.Debug($"Connection state is {connectionState}");
                RaiseConnectionStateChanged(connectionState);
            }
        }
示例#2
0
 public CGConnectionStateEventArgs(CGConnectionState connectionState)
 {
     ConnectionState = connectionState;
 }
示例#3
0
 /// <summary>
 ///     Конструктор
 /// </summary>
 public CGConnectionStateChange(CGConnectionState connectionState)
 {
     ConnectionState = connectionState;
 }
示例#4
0
 private void RaiseConnectionStateChanged(CGConnectionState state)
 {
     _state = state;
     ConnectionStateChanged?.Invoke(this, new CGConnectionStateEventArgs(state));
 }