void osf_SerialSelected(OpenSerialForm.SerialSelectedEventArgs e) { // set the conf of the serial serialPort.PortName = e.Port; serialPort.BaudRate = e.Rate; try { serialPort.Open(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace + ": " + ex.Message); uiconsole.WriteLine(ex.StackTrace + ": " + ex.Message); _continue = false; return; } try { _continue = true; if (readThread==null) readThread = new Thread(Read); // check if the thread have be stoped if (readThread.ThreadState == System.Threading.ThreadState.Aborted || readThread.ThreadState == System.Threading.ThreadState.Stopped) { readThread = new Thread(Read); readThread.Priority = ThreadPriority.Highest; readThread.Start(); } else readThread.Start(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace + ": " + ex.Message); uiconsole.WriteLine(ex.StackTrace + ": " + ex.Message); serialPort.Close(); _continue = false; return; } // flag the connection uiconsole.WriteLine("Serial Connected"); }
private void toolStripButton1_Click(object sender, EventArgs e) { OpenSerialForm osf = new OpenSerialForm(); osf.SerialSelected += osf_SerialSelected; osf.ShowDialog(); }
void osf_SerialSelected(OpenSerialForm.SerialSelectedEventArgs e) { var cam = new Cameras(e.Port, e.Rate) { CameraName = "Camera", Position = new Point() }; listBox1.Items.Add(cam); // Start the streaming cam.Start(); }