public virtual void Dispose() { try { StreamAccessLock.Wait(); _IsDisposed = true; _InputStream?.Dispose(); _InputStream = null; } finally { StreamAccessLock.Release(); } }
public virtual Windows.Foundation.IAsyncOperationWithProgress <IBuffer, uint> ReadAsync(IBuffer buffer, uint count, InputStreamOptions options) { try { StreamAccessLock.Wait(); if (_IsDisposed) { return(AsyncInfo.Run <IBuffer, uint>((token, progress) => { return Task.FromResult(buffer); })); } _CurrentPosition += count; return(_InputStream.ReadAsync(buffer, count, options)); } finally { StreamAccessLock.Release(); } }
private async Task ResetInputStream() { try { await StreamAccessLock.WaitAsync(); if (_IsDisposed) { return; } var inputStream = _InputStream; _InputStream = await ReadRequestAsync(_CurrentPosition); inputStream?.Dispose(); } finally { StreamAccessLock.Release(); } }