A FileStream
buffers the bytes it needs to write. If the buffer is full, all bytes are written (flushed) to the file. This write process might take some time.
As every byte being added to the FileStream
might cause a Flush
, the write functions have an async version. It is possible to write to the stream without waiting for the write to be finished.
Class StreamWriter makes it easier to write text to the FileStream
. Writing data to the StreamWriter
causes data being written to the underlying stream, and thus might cause a Flush
.
This makes functions like StreamWriter.Write(int)
potentially slow. However, there are no async versions of these functions, except to write chars or strings. There is even an async version to WriteLine
.
Are such functions not needed when I write fairly small objects like integers and doubles?