コード例 #1
0
 public void ProcessChunks(BlockingDictionary <int, byte[]> inputDictionary,
                           BlockingDictionary <int, byte[]> outputDictionary)
 {
     while (!inputDictionary.IsComplete())
     {
         try
         {
             var(id, chunk) = inputDictionary.GetFirstItem();
             var processedChunk = _contentProcessor.Process(chunk);
             outputDictionary.Add(id, processedChunk);
             _logger.Write($"Process chunk {id}");
         }
         catch (InvalidOperationException)
         {
             break;
         }
     }
 }
コード例 #2
0
        public void Write(BlockingDictionary <int, byte[]> outputDictionary, BinaryWriter binaryWriter)
        {
            var id = 0;

            while (!outputDictionary.IsComplete())
            {
                try
                {
                    var chunk = outputDictionary.GetByKey(id);
                    _timer.Start();
                    binaryWriter.Write(chunk);
                    _timer.Stop();
                    _logger.Write($"Write chunk {id}");
                    id++;
                }
                catch (InvalidOperationException)
                {
                    break;
                }
            }
        }
コード例 #3
0
        public void Write(BlockingDictionary <int, byte[]> outputDictionary, BinaryWriter binaryWriter)
        {
            var id = 0;

            while (!outputDictionary.IsComplete())
            {
                try
                {
                    var chunk          = outputDictionary.GetByKey(id);
                    var contentToWrite = BitConverter.GetBytes(chunk.Length).Concat(chunk).ToArray();
                    _timer.Start();
                    binaryWriter.Write(contentToWrite);
                    _timer.Stop();
                    _logger.Write($"Write compressed chunk {id}, length {chunk.Length}");
                    id++;
                }
                catch (InvalidOperationException)
                {
                    break;
                }
            }
        }