protected virtual async Task SetUnderlyingStreamAsync(CancellationToken cancellationToken) { TryDisposeUnderlyingStream(); UnderlyingStream = await StreamProvider.GetStreamAsync(Position, cancellationToken).ConfigureAwait(false); if (UnderlyingStream == null) { throw new InvalidOperationException("Failed to retrieve underlying stream"); } }