I'm new to C #. I made a program, which is continuously reading the serial port data and showing in a textBox.
So far, everything works fine. The problem occurs when I try to close the port, it gives the following error
The I / O operation has been aborted due to an thread output or an application request;
I have read several threads on the same subject, but I have not solved it yet.
Below is part of the code.
public FormRelatorio()
{
InitializeComponent();
FormPrincipal.SerialPortCommunicator.SerialPort.DataReceived +=
new SerialDataReceivedEventHandler(SerialPort_DataReceived_RL);
}
private void SerialPort_DataReceived_RL(object sender, SerialDataReceivedEventArgs e)
{
rxSerialRL = FormPrincipal.SerialPortCommunicator.SerialPort.ReadLine();
BeginInvoke(new Fdelegate(recebeSerial), new object[] { rxSerialRL });
}
public void recebeSerial(string a)
{
textBoxTesteMSG.Text = a;
}