private void MainForm_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(COMtoMDB_App.Properties.Settings.Default.MBDPath)) { DBExchange.PathToBD = COMtoMDB_App.Properties.Settings.Default.MBDPath; } if (!String.IsNullOrEmpty(COMtoMDB_App.Properties.Settings.Default.PortNumber)) { RS232port.PortNumber = COMtoMDB_App.Properties.Settings.Default.PortNumber; } if (COMtoMDB_App.Properties.Settings.Default.BaudRate > 0) { RS232port.BaudRate = COMtoMDB_App.Properties.Settings.Default.BaudRate; } if (COMtoMDB_App.Properties.Settings.Default.Timeouts > 0) { RS232port.Timeouts = COMtoMDB_App.Properties.Settings.Default.Timeouts; } DBExchange.ConnectToDB(); DBExchange.LoadTable(); Port = new RS232port(); Port.OpenPort(); }
public void Read() { while (Continue && RS232.IsOpen) { try { RecievedData = RS232.ReadLine(); //DBExchange.AddLine(RecievedData, true); //MainForm.textBox.Invoke(new Action(() => { DBExchange.AddLine(RecievedData, true); })); MainForm.listBox.Invoke(new Action(() => { DBExchange.AddLine(RecievedData, true); DBExchange.LoadTable(); })); } catch (TimeoutException) { } } RS232port.RS232.Close(); }