Exemple #1
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;
                }
            }
        }
        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;
                }
            }
        }