private void openBATFileToolStripMenuItem_Click(object sender, EventArgs e) { string path = WorkWithCMD.OpenFile(); if (path != "") { Task <string> task = Task.Run(() => WorkWithCMD.GetStartAsync(path)); task.Wait(); Form3 form3 = new Form3(); form3.richTextBox1.Text = task.Result; form3.ShowDialog(); } //MessageBox.Show(task.Result); //string output = WorkWithCMD.GetStartAsync(path); }
private async void BtnExecute_Click(object sender, EventArgs e) { await Task.Delay(100).ConfigureAwait(false); string t1 = "", t2 = ""; object state = new object(); param.Invoke((MethodInvoker) delegate { t1 = GetParameter(); }); textQuery.Invoke((MethodInvoker) delegate { t2 = GetArguments(); }); #region Parse string arguments #endregion //Set TimeOut WorkWithCMD.TimeOut = 10; Task <string> task = Task.Factory.StartNew(() => WorkWithCMD.ExecuteCommandCMD(t1, t2)); Task <string> task1 = Task.Factory.StartNew(() => WorkWithCMD.ExecuteCommandCMD(t1, t2)); Task.WaitAll(task); bool b = ((task.Result == null)) ? true : false; if (!b) { GetOutput(task.Result); } else { GetOutput("ERROR"); } }