private void Form1_Load(object sender, EventArgs e) { //turn on the lights FlashLighter.RunWorkerAsync(); //select camera to get real-time image from phone display CameraSelection cselect = new CameraSelection(); DialogResult dresult = cselect.ShowDialog(); if (dresult == DialogResult.OK) { try { imageReceiver = new ImageReceiver(cselect.camNumber); } catch (NullReferenceException exception) { MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } getStreamVideoFromWebCam(); } else { this.Close(); } //select COM-port for phone manipulation COMSelection cmselect = new COMSelection(); dresult = cmselect.ShowDialog(); if (dresult == DialogResult.OK) { manipulator = new Manipulator(cmselect.portName); } else { this.Close(); } }