Closed stmax82 closed 6 years ago
Example code:
using System.IO.Ports;
using ZWaveLib;
namespace ConsoleApp1 {
public class Program {
public static void Main(string[] args) {
using (var controller = new ZWaveController("COM4")) {
controller.Connect();
} // after this line the port should be closed
// Thread.Sleep(100); // <-- helps a bit, but not always.
// try to open the port again
using (var port = new SerialPort("COM4")) {
port.Open(); // <-- throws because port is still in use!
}
}
}
}
When I dispose the ZWaveController the serial port sometimes stays open / cannot be opened again.
Sometimes a Thread.Sleep helps before opening the port again, but sometimes it doesn't and the port stays open forever.
Is this a known problem / what can I do about it?