public override void Flush(bool flushToDisk)
{
// WinRT streams are not buffered, however the WinRT stream will be wrapped in a BufferedStream
// Flush & FlushAsync will flush the internal managed buffer of the BufferedStream wrapper
// The WinRT stream only exposes FlushAsync which flushes to disk.
// The managed Stream adapter does nothing for Flush() and forwards to WinRT for FlushAsync (flushing to disk).
if (flushToDisk)
{
// FlushAsync() will do the write to disk when it hits the WinRT->NetFx adapter
Task flushTask = _innerStream.FlushAsync();
flushTask.Wait();
}
else
{
// Flush doesn't write to disk
_innerStream.Flush();
}
}