///<inheritdoc /> public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { ThrowIfDisposed(); if (_memoryStatus == MemoryFlag.AutoOverFlowToDisk && _isInMemory && count + UnderlyingStream.Position > _threshholdSize) { OverflowToPersistentStream(); } return(UnderlyingStream.WriteAsync(buffer, offset, count, cancellationToken)); }