Click here to Skip to main content
15,889,844 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
so I have an C# WinForm that use

C#
SerialPort SerialPort1 = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
SerialPort1.Open()
SerialPort1.DataReceived += new SerialDataReceivedEventHandler(...)


to listen on several Virtual COM Ports that Created by other Software(I can't control it)

So generally it goes well except When the other Software is dead or gone, the Virtual COM port it created is also gone or missing

So my WinForm App fail of course because there is no COM1 to listen to

Question: How should I detect when there is no COM port to listen??
C#
SerialPort1.IsOpen() still return true, SerialPort1 != null


Thank you so much for your reply
Posted
Updated 1-Aug-14 6:20am
v2
Comments
Aydin Homay 28-Feb-18 8:23am    
Keep pulling, no other solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900