private void btnAddApplication_Click(object sender, EventArgs e) { try { newProgram.Show(); //Try to show the AddProgram window newProgram.Focus(); //Try to focus the AddProgram window } catch (ObjectDisposedException) //If object was destroyed (opened previously then closed) { newProgram = new AddProgram(); //Create a new one newProgram.Show(); //Show it newProgram.Focus(); //Focus it } }
private void setup() { newProgram = new AddProgram(); timeclock = new System.Timers.Timer(sleeptime); timeclock.Elapsed += OnTimedEvent; // https://goo.gl/nOvmlw outputTextBox.Clear(); //TODO remove hardcoding //listBox1.Items.Add("Teamviewer"); foreach (ServiceController serController in services) { listBox1.Items.Add(serController.ServiceName); // TODO decide on ServiceName or DisplayName } }