public override async Task OpenAsync(TimeoutHelper timeoutHelper)
        {
            if (Logging.IsEnabled)
            {
                Logging.Enter(this, timeoutHelper, nameof(OpenAsync));
            }

            lock (_lock)
            {
                if (_disposed)
                {
                    return;
                }

                _closed = false;
            }

            try
            {
                using var cts = new CancellationTokenSource(timeoutHelper.GetRemainingTime());
                await _amqpUnit.OpenAsync(cts.Token).ConfigureAwait(false);
            }
            finally
            {
                if (Logging.IsEnabled)
                {
                    Logging.Exit(this, timeoutHelper, nameof(OpenAsync));
                }
            }
        }
        public override async Task OpenAsync(TimeoutHelper timeoutHelper)
        {
            if (Logging.IsEnabled)
            {
                Logging.Enter(this, timeoutHelper, $"{nameof(OpenAsync)}");
            }
            lock (_lock)
            {
                if (_disposed)
                {
                    return;
                }

                _closed = false;
            }

            try
            {
                await _amqpUnit.OpenAsync(timeoutHelper.RemainingTime()).ConfigureAwait(false);
            }
            finally
            {
                if (Logging.IsEnabled)
                {
                    Logging.Exit(this, timeoutHelper, $"{nameof(OpenAsync)}");
                }
            }
        }
Beispiel #3
0
        public override async Task OpenAsync(CancellationToken cancellationToken)
        {
            if (Logging.IsEnabled)
            {
                Logging.Enter(this, cancellationToken, $"{nameof(OpenAsync)}");
            }

            try
            {
                cancellationToken.ThrowIfCancellationRequested();

                await _amqpUnit.OpenAsync(_operationTimeout).ConfigureAwait(false);
            }
            catch (Exception exception) when(!exception.IsFatal() && !(exception is OperationCanceledException))
            {
                Exception newException = AmqpClientHelper.ToIotHubClientContract(exception);

                if (newException != exception)
                {
                    throw newException;
                }
                else
                {
                    // Maintain the original stack.
                    throw;
                }
            }
            finally
            {
                if (Logging.IsEnabled)
                {
                    Logging.Exit(this, cancellationToken, $"{nameof(OpenAsync)}");
                }
            }
        }
Beispiel #4
0
        public override async Task OpenAsync(CancellationToken cancellationToken)
        {
            if (Logging.IsEnabled)
            {
                Logging.Enter(this, cancellationToken, $"{nameof(OpenAsync)}");
            }
            cancellationToken.ThrowIfCancellationRequested();
            lock (_lock)
            {
                if (_disposed)
                {
                    return;
                }

                _closed = false;
            }

            try
            {
                await _amqpUnit.OpenAsync(_operationTimeout).ConfigureAwait(false);
            }
            finally
            {
                if (Logging.IsEnabled)
                {
                    Logging.Exit(this, cancellationToken, $"{nameof(OpenAsync)}");
                }
            }
        }