diff --git a/src/XmlNotepad/AsyncXslt.cs b/src/XmlNotepad/AsyncXslt.cs index 6f15a660..047e5143 100644 --- a/src/XmlNotepad/AsyncXslt.cs +++ b/src/XmlNotepad/AsyncXslt.cs @@ -120,28 +120,10 @@ public void Cancel() public override bool CanWrite => this.inner.CanWrite; - public override long Length - { - get - { - if (!disposed) - { - lastLength = this.inner.Length; - } - return lastLength; - } - } + public override long Length => lastLength; - public override long Position - { - get - { - if (!disposed) - { - lastPosition = this.inner.Position; - } - return lastPosition; - } + public override long Position { + get => lastPosition; set => this.inner.Position = value; } @@ -156,17 +138,24 @@ public override int Read(byte[] buffer, int offset, int count) { throw new OperationCanceledException(); } - return this.inner.Read(buffer, offset, count); + int rc = this.inner.Read(buffer, offset, count); + lastPosition = this.inner.Position; + lastLength = this.inner.Length; + return rc; } public override long Seek(long offset, SeekOrigin origin) { - return this.inner.Seek(offset, origin); + var pos = this.inner.Seek(offset, origin); + lastPosition = this.inner.Position; + lastLength = this.inner.Length; + return pos; } public override void SetLength(long value) { this.inner.SetLength(value); + lastLength = this.inner.Length; } public override void Write(byte[] buffer, int offset, int count) @@ -176,6 +165,8 @@ public override void Write(byte[] buffer, int offset, int count) { this.EstimatedSize = this.Position * 2; } + lastPosition = this.inner.Position; + lastLength = this.inner.Length; if (cancelled) { disposed = true;