Esempio n. 1
0
        public override void ReadBytes()
        {
            using (var fsInput = new FileStream(FileSource, FileMode.Open, FileAccess.Read))
            {
                var length      = _fileSize;
                var blockLength = BlockProcessingLength;

                while (blockLength > 0 && !ForceStopped)
                {
                    var bytesArray = new byte[blockLength];
                    var readCount  = fsInput.Read(bytesArray, 0, bytesArray.Length);

                    InputQueue.Push(new BytesBlock(ReadedBlockCount, bytesArray));

                    ++ReadedBlockCount;
                    length -= readCount;

                    blockLength = length < blockLength ? length : blockLength;
                }

                if (ForceStopped)
                {
                    return;
                }
                InputQueue.Complete();
            }
        }
        public override void ReadBytes()
        {
            using (var fsInput = new FileStream(FileSource, FileMode.Open, FileAccess.Read))
            {
                var binaryFormatter = new BinaryFormatter();

                while (fsInput.Position < fsInput.Length && !ForceStopped)
                {
                    InputQueue.Push((BytesBlock)binaryFormatter.Deserialize(fsInput));
                    ++ReadedBlockCount;
                }

                if (ForceStopped)
                {
                    return;
                }
                InputQueue.Complete();
            }
        }