private void btnOpenCommandPromptSYSTEM_Click(object sender, EventArgs e) { txtOutput.Clear(); TextWriter tw = new TextBoxWriter(txtOutput); btnOpenCommandPromptSYSTEM.Enabled = false; SystemCommandPromptLauncher launcher = new SystemCommandPromptLauncher(tw); Thread t = new Thread(DoLaunch); t.Name = "SystemCommandPromptLauncher"; t.Start(launcher); }
void DoLaunch(object arg) { SystemCommandPromptLauncher launcher = (SystemCommandPromptLauncher)arg; Exception failure = null; try { launcher.LaunchIt(); } catch (Exception ex) { failure = ex; } BeginInvoke((MethodInvoker) delegate() { AfterLaunch(failure); }); }