Пример #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;
            }
        }
        /// <inheritdoc/>
        public void Dispose()
        {
            _faultTolerantSession?.Dispose();
            _faultTolerantSession = null;

            _refreshTokenTimer?.Dispose();
            _refreshTokenTimer = null;

            _clientWebSocketTransport?.Dispose();
            _clientWebSocketTransport = null;
        }
 /// <inheritdoc/>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         _faultTolerantSendingLink.Dispose();
         _fileNotificationReceiver.Dispose();
         _feedbackReceiver.Dispose();
         Connection.Dispose();
         _httpClientHelper.Dispose();
     }
 }
Пример #4
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;

            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);
            }
        }
Пример #5
0
 /// <inheritdoc/>
 public void Dispose()
 {
     _faultTolerantReceivingLink.Dispose();
 }
 /// <inheritdoc/>
 public void Dispose()
 {
     _faultTolerantSession.Dispose();
 }