The while loop stop when data reads x, but the buttonTransfer button never gets enabled
and the MessageBox message never shows up, but the program does not either freeze. What can be the problem with this code?
and the MessageBox message never shows up, but the program does not either freeze. What can be the problem with this code?
C#:
try
{
buttonTransfer.Enabled = false;
port = new SerialPort();
port.BaudRate = 9600;
port.PortName = getValueNew;
port.Open();
port.Write("1");
ch = 1;
while (data != "x")
{
data = port.ReadLine();
this.Invoke(new EventHandler(displaydata_event));
}
buttonTransfer.Enabled = true;
MessageBox.Show("Done!");
port.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}