public override int Read(byte[] buffer, int offset, int count)
{
lock (ParentStream)
{
var ParentStreamPositionToRestore = ParentStream.Position;
ParentStream.Position = ThisStart + Position;
if (Position + count > Length)
{
count = (int)(Length - Position);
}
try
{
//Console.WriteLine("Read(position: {0}, count: {1})", Position, count);
return base.Read(buffer, offset, count);
}
finally
{
Seek(count, SeekOrigin.Current);
ParentStream.Position = ParentStreamPositionToRestore;
}
}
}