Detecting when a SerialPort gets disconnected

后端 未结 7 983
天命终不由人
天命终不由人 2020-12-01 09:25

I have an open SerialPort and receive data through the DataReceived event.

Is there any way to detect if the SerialPort gets d

7条回答
  •  北海茫月
    2020-12-01 10:21

    The problem is that IsOpen value is only set back to false when the Close method is executed.

    You could try caputuring the WM_DEVICECHANGE message and using that.

    http://msdn.microsoft.com/en-us/library/windows/desktop/aa363480(v=vs.85).aspx

提交回复
热议问题