private void goButton_Click(object sender, EventArgs e) { if(!goButton.Enabled) return; goButton.Enabled = false; List<ProcessCaller> pcs = new List<ProcessCaller>(); foreach (DirectoryDataGridViewRow directoryDataGridViewRow in this.operationControlCommandsDataGridView.Rows){ if (directoryDataGridViewRow.Cells[2] is DataGridViewCheckBoxCell){ if (!(bool)((DataGridViewCheckBoxCell)directoryDataGridViewRow.Cells[2]).EditedFormattedValue){ continue; } } ProcessCaller pc = new ProcessCaller("cmd.exe"); if (directoryDataGridViewRow.Cells[0] is DirectoryDataGridViewTextBoxCell){ pc.setDirectory(((DirectoryDataGridViewTextBoxCell)directoryDataGridViewRow.Cells[0]).getDirectory()); } if (directoryDataGridViewRow.Cells[1] is DataGridViewComboBoxCell){ pc.setCmd(PreloadedConfigurationGetterService.getInstance().getCommand(this.configFile, ((string)((DataGridViewComboBoxCell)directoryDataGridViewRow.Cells[1]).Value).Trim() )); } if (directoryDataGridViewRow.Cells[3] is DataGridViewCheckBoxCell){ //display pc.setPrefix((bool)((DataGridViewCheckBoxCell)directoryDataGridViewRow.Cells[3]).EditedFormattedValue ? "/k" : "/c"); } if (directoryDataGridViewRow.Cells[4] is DataGridViewCheckBoxCell){ //autoexit if ((bool)((DataGridViewCheckBoxCell)directoryDataGridViewRow.Cells[4]).EditedFormattedValue){ pc.setAutoExit(); } } if (directoryDataGridViewRow.Cells[5] is DataGridViewCheckBoxCell){ //wait for exit if ((bool)((DataGridViewCheckBoxCell)directoryDataGridViewRow.Cells[5]).EditedFormattedValue || !(bool)((DataGridViewCheckBoxCell)directoryDataGridViewRow.Cells[5]).Visible){ pc.setWaitForExit(); } } pc.setSpecial(""); pcs.Add(pc); //string text3 = "/c " + directory.ToCharArray()[0] + ": && cd " + directory + " && " + directory; //Console.WriteLine(text3); } //ProcessThreadHandler Cursor.Current = Cursors.WaitCursor; try{ ProcessHandle blocker = null; foreach (ProcessCaller pc in pcs){ if (pc.echo()){ cmdTextBox.Text = pc.getCmd(); } ProcessHandle ph = new ProcessHandle(pc); ProcessThreadHandler pht = new ProcessThreadHandler(ph); Thread handleCommand = new Thread(new ThreadStart(pht.Handle)); handleCommand.Start(); if(pc.waitForExit()){ ph.setBlockedBy(blocker); } blocker = ph; ((UserControlForm)this.Parent).addNewProcessHandleToQueueAndBottom(ph); } } finally { Cursor.Current = Cursors.Default; } goButton.Enabled = true; }