/// <summary> /// Intialize w/ a specific handler. /// </summary> /// <param name="numberOfItemsToProcessPerDequeue">Number of items to process per dequeue.</param> /// <param name="handler">Action to be called on item dequeue.</param> public QueueProcessor(int numberOfItemsToProcessPerDequeue, Action <IList <T> > handler) { _queue = new Queue <T>(); _state = QueueProcessState.Idle; _handler = handler; _numberToDequeuAtOnce = numberOfItemsToProcessPerDequeue; }
/// <summary> /// Initializes a new instance of the <see cref="QueueStatus"/> class. /// </summary> /// <param name="state">The state.</param> /// <param name="countItemsRemaining">The count.</param> /// <param name="lastProcessDate">The last process date.</param> /// <param name="numberOfTimesProcessed">Number of times items were processed.</param> /// <param name="elaspedTime">Time elapsed since the last item was processed.</param> /// <param name="totalProcessed">Total number of items processed.</param> /// <param name="dequeueSize">Size of the dequeue.</param> public QueueStatus(QueueProcessState state, int countItemsRemaining, DateTime lastProcessDate, int numberOfTimesProcessed, TimeSpan elaspedTime, int totalProcessed, int dequeueSize) { State = state; Count = countItemsRemaining; NumberOfTimesProcessed = numberOfTimesProcessed; LastProcessDate = lastProcessDate; DequeueSize = dequeueSize; ElapsedTimeSinceLastProcessDate = elaspedTime; TotalProcessed = totalProcessed; }
/// <summary> /// Updates the state. /// </summary> /// <param name="newState">The new state.</param> /// <param name="performLock">if set to <c>true</c> [perform lock].</param> protected void UpdateState(QueueProcessState newState, bool performLock) { if (performLock) { lock (_synObject) { _state = newState; } } else { _state = newState; } }
/// <summary> /// Initializes a new instance of the <see cref="QueueProcessor<T>"/> class. /// </summary> public QueueProcessor() { _queue = new Queue <T>(); _state = QueueProcessState.Idle; }