I recently built a serial port communication application and am looking for a way to handle an exception in the event that a serial port is lost while the app is running. For example if my serial cable became disconnected during use of the application my app would crash. What is a good way to handle this issue?
Asked
Active
Viewed 269 times
0
-
1That doesn't cause an exception. Serial ports are far too primitive to have anything like a "device was lost" kind of failure mode. The DsrHolding and CtsHolding properties will turn off, that's all. Disconnecting the USB cable of an emulator, that will produce a loud bang in many cases. USB drivers in general do not deal with this well, they'll make the device disappear even though you have it opened. A bit like jerking the hard drive out of your machine without shutting down first. Dzzz. – Hans Passant Feb 03 '14 at 23:35
1 Answers
0
Handle the event called by the class (SerialPort.ErrorReceived
) or simply catch the exception thrown and handle it.

Blindy
- 65,249
- 10
- 91
- 131