private void Form1_Closed(object sender, EventArgs e) { if (_mySerialPort != null) { _mySerialPort.Dispose(); _mySerialPort = null; } }
private void btn_Stop_Click(object sender, EventArgs e) { if (_mySerialPort != null) { _mySerialPort.Dispose(); _mySerialPort = null; } }
private void btn_Start_Click(object sender, EventArgs e) { _mySerialPort = new MySerialPort("COM9:"); _mySerialPort.eventOnMessage += new MySerialPort.delegateOnMessage(_mySerialPort_eventOnMessage); _mySerialPort.eventOnConnectEvent += new MySerialPort.delegateOnConnect(_mySerialPort_eventOnConnectEvent); }