Exemplo n.º 1
0
        public void Start()
        {
            if (_started)
            {
                return;
            }

            try
            {
                _serviceContainer.Start();

                _consumerPool = new ThreadPoolConsumerPool(this, _eventChannel, _receiveTimeout)
                {
                    MaximumConsumerCount = MaximumConsumerThreads,
                };
                _consumerPool.Start();
            }
            catch (Exception)
            {
                if (_consumerPool != null)
                {
                    _consumerPool.Dispose();
                }

                throw;
            }

            _started = true;
        }
Exemplo n.º 2
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }
            if (disposing)
            {
                if (_consumerPool != null)
                {
                    _consumerPool.Stop();
                    _consumerPool.Dispose();
                    _consumerPool = null;
                }

                if (_serviceContainer != null)
                {
                    _serviceContainer.Stop();
                    _serviceContainer.Dispose();
                    _serviceContainer = null;
                }

                if (ControlBus != this)
                {
                    ControlBus.Dispose();
                }

                if (_performanceCounterConnection != null)
                {
                    _performanceCounterConnection.Dispose();
                    _performanceCounterConnection = null;
                }

                _eventChannel = null;

                Endpoint = null;

                if (_counters != null)
                {
                    _counters.Dispose();
                    _counters = null;
                }

                EndpointCache.Dispose();
            }
            _disposed = true;
        }