public void Start() { string[] ports = SerialPort.GetPortNames(); for (int i = 0; i < ports.Length; i++) { _serialCommPort = new SerialPort(ports[i], 9600); try { _serialCommPort.Open(); } catch (Exception e) { } if (_serialCommPort.IsOpen == true) { if (this._checkDevice()) { this.IsDeviceConnected = true; this._uart = new UART(ref this._serialCommPort, this.UARTDataArrived); this._uartWorker = new Thread(new ThreadStart(this._uart.UartHandler)); this._uartWorker.Start(); break; } else { _serialCommPort.Close(); } } } }