示例#1
0
        private async Task InitializeAsync(CancellationToken cancellationToken)
        {
            _channelSource = await _binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false);

            try
            {
                _channel = await _channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false);
            }
            catch (Exception ex) when(RetryableReadOperationExecutor.ShouldConnectionAcquireBeRetried(this, ex))
            {
                ReplaceChannelSource(await _binding.GetReadChannelSourceAsync(cancellationToken).ConfigureAwait(false));
                ReplaceChannel(await _channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false));
            }
        }
示例#2
0
        private async Task InitializeAsync(CancellationToken cancellationToken)
        {
            _channelSource = await _binding.GetWriteChannelSourceAsync(cancellationToken).ConfigureAwait(false);

            var serverDescription = _channelSource.ServerDescription;

            try
            {
                _channel = await _channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false);
            }
            catch (MongoConnectionPoolPausedException)
            {
                if (RetryableWriteOperationExecutor.ShouldConnectionAcquireBeRetried(this, serverDescription))
                {
                    ReplaceChannelSource(await _binding.GetWriteChannelSourceAsync(cancellationToken).ConfigureAwait(false));
                    ReplaceChannel(await _channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false));
                }
                else
                {
                    throw;
                }
            }
        }
        private async Task InitializeAsync(CancellationToken cancellationToken)
        {
            _channelSource = await _binding.GetWriteChannelSourceAsync(cancellationToken).ConfigureAwait(false);

            _channel = await _channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false);
        }