예제 #1
0
        public async Task EstablishNewChannel(CancellationToken cancellationToken)
        {
            var channel = await _executor.Execute(() => _factory.Create(cancellationToken), cancellationToken).ConfigureAwait(false);

            var oldChannel = _channel;

            _channel = channel;

            if (oldChannel is not null)
            {
                await oldChannel.DisposeAsync().ConfigureAwait(false);
            }
        }
예제 #2
0
        private async void SetupChannel()
        {
            try
            {
                var channel = await _factory.Create(CancellationTokenSource.Token).ConfigureAwait(false);

                await _producer.SetChannel(channel).ConfigureAwait(false);
            }
            catch
            {
                // ignored
            }
        }
        private async void SetupChannel()
        {
            IProducerChannel?channel = null;

            try
            {
                channel = await _factory.Create(CancellationTokenSource.Token).ConfigureAwait(false);

                _producer.SetChannel(channel);
            }
            catch
            {
                if (channel != null)
                {
                    await channel.DisposeAsync().ConfigureAwait(false);
                }
            }
        }