public async void Run()
        {
            LastActiveTime = DateTime.Now;
            while (_isPaused)
            {
                _logger.InfoFormat("Command mailbox is pausing and we should wait for a while, aggregateRootId: {0}", AggregateRootId);
                _pauseWaitHandle.WaitOne(1000);
            }
            ProcessingCommand processingCommand = null;

            try
            {
                _processingWaitHandle.Reset();
                _isProcessingCommand = true;
                var count = 0;
                while (_consumingSequence < _nextSequence && count < _batchSize)
                {
                    processingCommand = GetProcessingCommand(_consumingSequence);
                    if (processingCommand != null)
                    {
                        await _messageHandler.Handle(processingCommand);
                    }
                    _consumingSequence++;
                    count++;
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Command mailbox run has unknown exception, aggregateRootId: {0}, commandId: {1}", AggregateRootId, processingCommand != null ? processingCommand.Message.Id : string.Empty), ex);
                Thread.Sleep(1);
            }
            finally
            {
                _isProcessingCommand = false;
                _processingWaitHandle.Set();
                Exit();
                if (_consumingSequence < _nextSequence)
                {
                    TryRun();
                }
            }
        }
 public ProcessingCommandMailbox(string aggregateRootId, IProcessingCommandHandler messageHandler, ILogger logger)
     : base(aggregateRootId, ENodeConfiguration.Instance.Setting.CommandMailBoxPersistenceMaxBatchSize, false, (x => messageHandler.Handle(x)), null, logger)
 {
 }