public IDataReader Execute(CommandBehavior behavior)
        {
            Exception exception = null;

            _startDate = LocalTime.Default.Now;
            _startTick = Stopwatch.GetTimestamp();

            try
            {
                _reader = _command.ExecuteReader(behavior);
            }
            catch (Exception e)
            {
                exception = e;
                throw;
            }
            finally
            {
                var ticks    = Stopwatch.GetTimestamp() - _startTick;
                var duration = StopwatchTimeSpan.ToInt32(ticks, 1000);
                var filter   = _connection.Filter;
                _contains = exception != null || filter == null ||
                            filter.Contains(_connection.UserName, _connection.HostName, _command);

                if (_contains)
                {
                    _connection.CommandExeucte(_command, _startDate, duration, exception);
                    _logged = true;
                }
            }

            return(this);
        }
    private void ManagePoolDequeuers(object state)
    {
        if (_pool.QueuedItemCount > 0)
        {
            var addableThreadCount = _pool.MaxThreadCount - _pool.Dequeuers.Count;
            var count = Math.Min(addableThreadCount, 5);

            for (var i = 0; i < count; i++)
            {
                var callback = _waitCallbackFactory.CreateWaitCallback();
                var dequeuer = new WorkerThreadPoolDequeuer(callback);
                _pool.Dequeuers.Add(dequeuer);
                dequeuer.Thread.Start();
            }
        }
        else
        {
            var timestamp = Stopwatch.GetTimestamp();
            var dequeuers = new List <WorkerThreadPoolDequeuer>();
            var threads   = new WorkerThreadCollection();

            foreach (var dequeuer in _pool.Dequeuers)
            {
                var milliseconds = StopwatchTimeSpan.ToInt32(timestamp - dequeuer.LastActivityTimestamp, 1000);

                if (milliseconds >= 10000)
                {
                    dequeuers.Add(dequeuer);
                    threads.Add(dequeuer.Thread);
                }
            }

            foreach (var dequeuer in dequeuers)
            {
                _pool.Dequeuers.Remove(dequeuer);
            }

            var stopEvent = new ManualResetEvent(false);
            threads.Stop(stopEvent);
            stopEvent.WaitOne();
        }
    }