SerialPort.Write
is a blocking operation, yes. However, there are two buffers to be considered: The serial device, and the SerialPort
buffers.
If the SerialPort
object is configured to buffer, the write only blocks if there isn't enough room in that buffer. It will block for as long as it takes the buffer to empty enough to fit the new data. Otherwise it fills the buffer and returns.
If the SerialPort
object does not buffer, the Write operation blocks only for as long as it takes to transfer the data to the serial device. That device has its own buffer(*), so the block may take far less time than the time it will take to send the data.
SerialPort.BytesToWrite
includes both data in the device's buffer and data in the SerialPort
object's buffer.
(*) Older UARTs did not have buffers and newer ones do but can be configured to not buffer.