Exemple #1
0
        /// <summary>
        ///   Closes the connection to the transport sender instance.
        /// </summary>
        ///
        /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request to cancel the operation.</param>
        ///
        public override async Task CloseAsync(CancellationToken cancellationToken)
        {
            if (_closed)
            {
                return;
            }

            _closed = true;

            try
            {
                cancellationToken.ThrowIfCancellationRequested <TaskCanceledException>();

                if (_sendLink?.TryGetOpenedObject(out var _) == true)
                {
                    cancellationToken.ThrowIfCancellationRequested <TaskCanceledException>();
                    await _sendLink.CloseAsync().ConfigureAwait(false);
                }

                _sendLink?.Dispose();
            }
            catch (Exception)
            {
                _closed = false;
                throw;
            }
        }
Exemple #2
0
        public async override Task CloseAsync()
        {
            await faultTolerantSendingLink.CloseAsync().ConfigureAwait(false);

            await feedbackReceiver.CloseAsync().ConfigureAwait(false);

            await fileNotificationReceiver.CloseAsync().ConfigureAwait(false);

            await iotHubConnection.CloseAsync().ConfigureAwait(false);
        }
        public Task CloseAsync()
        {
            Logging.Enter(this, nameof(CloseAsync));

            try
            {
                return(_faultTolerantSession.CloseAsync());
            }
            finally
            {
                Logging.Exit(this, nameof(CloseAsync));
            }
        }
        // This call is executed over AMQP.
        public async override Task CloseAsync()
        {
            Logging.Enter(this, $"Closing AmqpServiceClient", nameof(CloseAsync));

            await _faultTolerantSendingLink.CloseAsync().ConfigureAwait(false);

            await _feedbackReceiver.CloseAsync().ConfigureAwait(false);

            await _fileNotificationReceiver.CloseAsync().ConfigureAwait(false);

            await Connection.CloseAsync().ConfigureAwait(false);

            Logging.Exit(this, $"Closing AmqpServiceClient", nameof(CloseAsync));
        }
        /// <summary>
        ///   Closes the connection to the transport sender instance.
        /// </summary>
        ///
        /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request to cancel the operation.</param>
        ///
        public override async Task CloseAsync(CancellationToken cancellationToken)
        {
            if (_closed)
            {
                return;
            }

            _closed = true;

            var clientId   = GetHashCode().ToString();
            var clientType = GetType();

            try
            {
                ServiceBusEventSource.Log.ClientCloseStart(clientType, _entityName, clientId);
                cancellationToken.ThrowIfCancellationRequested <TaskCanceledException>();

                if (_sendLink?.TryGetOpenedObject(out var _) == true)
                {
                    cancellationToken.ThrowIfCancellationRequested <TaskCanceledException>();
                    await _sendLink.CloseAsync().ConfigureAwait(false);
                }

                _sendLink?.Dispose();
            }
            catch (Exception ex)
            {
                _closed = false;
                ServiceBusEventSource.Log.ClientCloseError(clientType, _entityName, clientId, ex.Message);

                throw;
            }
            finally
            {
                ServiceBusEventSource.Log.ClientCloseComplete(clientType, _entityName, clientId);
            }
        }
Exemple #6
0
 public override Task CloseAsync()
 {
     return(link.CloseAsync());
 }
 public Task CloseAsync()
 {
     return(_faultTolerantSession.CloseAsync());
 }