private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (Logging.IsEnabled)
            {
                Logging.Info(this, disposing, nameof(Dispose));
            }

            if (disposing)
            {
                _amqpIotConnection?.SafeClose();
                _lock?.Dispose();
                _amqpIotConnector?.Dispose();
                lock (_unitsLock)
                {
                    _amqpUnits.Clear();
                }
                _amqpAuthenticationRefresher?.Dispose();
            }

            _disposed = true;
        }
示例#2
0
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            if (disposing)
            {
                Logging.Enter(this, disposing, nameof(Dispose));

                Cleanup();
                if (!_deviceIdentity.IsPooling())
                {
                    _amqpConnectionHolder?.Dispose();
                }

                // For device sas authenticated clients the authentication refresher is associated with the AMQP unit itself,
                // so it needs to be explicitly disposed.
                _amqpAuthenticationRefresher?.StopLoop();
                _amqpAuthenticationRefresher?.Dispose();

                _sessionSemaphore?.Dispose();
                _messageReceivingLinkSemaphore?.Dispose();
                _messageReceivingCallbackSemaphore?.Dispose();
                _eventReceivingLinkSemaphore?.Dispose();
                _methodLinkSemaphore?.Dispose();
                _twinLinksSemaphore?.Dispose();

                Logging.Exit(this, disposing, nameof(Dispose));
            }
        }
示例#3
0
        private void Dispose(bool disposing)
        {
            try
            {
                if (Logging.IsEnabled)
                {
                    Logging.Enter(this, $"Disposed={_disposed}; disposing={disposing}", $"{nameof(AmqpConnectionHolder)}.{nameof(Dispose)}");
                }

                if (!_disposed)
                {
                    if (disposing)
                    {
                        _amqpIotConnection?.SafeClose();
                        _lock?.Dispose();
                        _amqpIotConnector?.Dispose();
                        lock (_unitsLock)
                        {
                            _amqpUnits.Clear();
                        }
                        _amqpAuthenticationRefresher?.Dispose();
                    }

                    _disposed = true;
                }
            }
            finally
            {
                if (Logging.IsEnabled)
                {
                    Logging.Exit(this, $"Disposed={_disposed}; disposing={disposing}", $"{nameof(AmqpConnectionHolder)}.{nameof(Dispose)}");
                }
            }
        }
示例#4
0
        private void Dispose(bool disposing)
        {
            try
            {
                if (Logging.IsEnabled)
                {
                    Logging.Enter(this, $"Device pooling={_deviceIdentity?.IsPooling()}; disposed={_disposed}; disposing={disposing}", $"{nameof(AmqpUnit)}.{nameof(Dispose)}");
                }

                if (!_disposed)
                {
                    if (disposing)
                    {
                        Cleanup();
                        if (!_deviceIdentity.IsPooling())
                        {
                            _amqpConnectionHolder?.Dispose();
                        }

                        // For device sas authenticated clients the authentication refresher is associated with the AMQP unit itself,
                        // so it needs to be explicitly disposed.
                        _amqpAuthenticationRefresher?.StopLoop();
                        _amqpAuthenticationRefresher?.Dispose();

                        _sessionSemaphore?.Dispose();
                        _messageReceivingLinkSemaphore?.Dispose();
                        _messageReceivingCallbackSemaphore?.Dispose();
                        _eventReceivingLinkSemaphore?.Dispose();
                        _methodLinkSemaphore?.Dispose();
                        _twinLinksSemaphore?.Dispose();

                        Logging.Exit(this, disposing, nameof(Dispose));
                    }
                }

                _disposed = true;
            }
            finally
            {
                if (Logging.IsEnabled)
                {
                    Logging.Exit(this, $"Device pooling={_deviceIdentity?.IsPooling()}; disposed={_disposed}; disposing={disposing}", $"{nameof(AmqpUnit)}.{nameof(Dispose)}");
                }
            }
        }
示例#5
0
        private void Dispose(bool disposing)
        {
            if (_disposed) return;

            if (disposing)
            {
                if (Logging.IsEnabled) Logging.Enter(this, disposing, $"{nameof(Dispose)}");
                if (SetNotUsable() == 0)
                {
                    OnUnitDisconnected?.Invoke(false, EventArgs.Empty);
                }

                _amqpAuthenticationRefresher?.Dispose();
                _amqpSession?.Abort();
                if (Logging.IsEnabled) Logging.Exit(this, disposing, $"{nameof(Dispose)}");
            }

            _disposed = true;
        }
示例#6
0
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (Logging.IsEnabled)
            {
                Logging.Info(this, disposing, $"{nameof(Dispose)}");
            }
            if (disposing)
            {
                AmqpConnection?.Abort();
                Lock?.Dispose();
                Connector?.Dispose();
                AmqpUnits?.Clear();
                AmqpAuthenticationRefresher?.Dispose();
                OnConnectionDisconnected?.Invoke(this, EventArgs.Empty);
            }

            _disposed = true;
        }