public static IEnumerable <FailOccurrenceDto> Dequeue(int count) { try { _queueLock.EnterWriteLock(); var returnCount = Math.Min(count, _failQueue.Count); var fails = new FailOccurrenceDto[returnCount]; for (var i = 0; i < returnCount; i++) { fails[i] = _failQueue.Dequeue(); } // if the queue holds less than the batch size, reset the queue signal if (_failQueue.Count < ConfigurationModel.Instance.ReportingMinimumBatchSize) { _queueSignal.Reset(); } return(fails); } finally { _queueLock.ExitWriteLock(); } }
public static void Enqueue(FailOccurrenceDto failReport) { // When recording a new fail report, make sure that the reporting worker is running ReportingWorker.Instance.Start(); try { _queueLock.EnterWriteLock(); _failQueue.Enqueue(failReport); // Signal that the queue is at least at the minimum batch size if (_failQueue.Count >= ConfigurationModel.Instance.ReportingMinimumBatchSize) { _queueSignal.Set(); } } finally { _queueLock.ExitWriteLock(); } }