4
I am new in C#. I made a program, which keeps continuously reading the data from the serial port and showing in a textbox.
Until then, everything works well. The problem occurs when I try to close the door, it gives the following error
The I/O operation was cancelled due to an outflow of thread or an application request;
I’ve read several threads on the same subject, but I still can’t solve.
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;
}
if you just change
BeginInvoke(new Fdelegate(recebeSerial), new object[] { rxSerialRL });
forrecebeSerial(rxSerialRL);
?– Rovann Linhalis