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); } }
public CGConnectionStateEventArgs(CGConnectionState connectionState) { ConnectionState = connectionState; }
/// <summary> /// Конструктор /// </summary> public CGConnectionStateChange(CGConnectionState connectionState) { ConnectionState = connectionState; }
private void RaiseConnectionStateChanged(CGConnectionState state) { _state = state; ConnectionStateChanged?.Invoke(this, new CGConnectionStateEventArgs(state)); }