Пример #1
0
        private void Reconnect()
        {
            TimeSpan reconnectDelay;

            lock (_syncRoot)
            {
                var shouldReconnect = _autoReconnect &&
                                      _eventProducer.State != ConnectionState.Open &&
                                      _eventProducer.State != ConnectionState.Connecting;

                if (!shouldReconnect)
                {
                    return;
                }

                reconnectDelay = _autoReconnectDelay;
            }

            if (reconnectDelay != TimeSpan.Zero)
            {
                Thread.Sleep(reconnectDelay);
            }
            _eventProducer.Connect();
        }