How can SerialPort.set_ReadTimeout throw IOException { NativeErrorCode = ERROR_OPERATION_ABORTED }?
After sending a message out a SerialPort
to a device, in preparation to read back its response, I tried setting the ReadTimeout
and got back a rather oddball error:
System.IO.IOException was unhandled
Message="The I/O operation has been aborted because of either a thread exit or an application request.\r\n"
Source="System"
StackTrace:
at System.IO.Ports.InternalResources.WinIOError(Int32 errorCode, String str)
at System.IO.Ports.InternalResources.WinIOError()
at System.IO.Ports.SerialStream.set_ReadTimeout(Int32 value)
at System.IO.Ports.SerialPort.set_ReadTimeout(Int32 value)
There are no other threads accessing the SerialPort
, and no event handlers regi开发者_如何学运维stered with it (which I hope would rule out interference from the implicit thread behind the port).
In any case, though, it just seems weird to me: how can SetCommTimeouts
fail with ERROR_OPERATION_ABORTED
?
精彩评论