public void StartConsuming() { ProcessingBlock currentProcessedBlock; while (_context.BlockQueue.TryDequeue(out currentProcessedBlock) && !_context.IsExecutionStopped()) { var decompressedBytes = GZipHelper.Decompress(currentProcessedBlock.BlockData); _context.ConsumerEventsManager.GetCurrentThreadEvent(currentProcessedBlock.BlockIndex).WaitOne(); _context.WriteFile.WriteToFile(decompressedBytes); _context.ConsumerEventsManager.GetNextThreadEvent(currentProcessedBlock.BlockIndex).Set(); CheckWorkDone(currentProcessedBlock); } }