public void ClosePort() { if (_port == null) { return; } _port.DataReceived -= OnDataReceived; _port.Dispose(); _port = null; }