I'm making an application that is reading the serial port and updating data in a WindowsForms application screen.
Sometimes when you try to close the program is locked. I'm using delegate.
What should I be doing wrong?
void sp1_LineReceived(object sender, LineReceivedEventArgs Args)
{
Invoke(new Action(() =>
{
// execute code
}));
}
Init
public FormPrincipal()
{
InitializeComponent();
spSistema.LineReceived += new LineReceivedEventHandler(sp1_LineReceived);
// next codes
}
Outher codes
public partial class FormPrincipal : Form
{
SerialPort spSimulador = new SerialPort();
public static PortaSerial spSistema = new PortaSerial();