0

I want to run 3 shell commands in parallel and get the output/result. Any idea how I can implement this?

I tried already "Parallel.for..." but I cannot catch the output/result. Her is the example:

Parallel.For(0, 3, number => {
   arg1 = array3[number];
   process.StartInfo.Arguments = arg1 + arg2;
   process.Start();

   output[number] = process.StandardOutput.ReadToEnd();
   process.WaitForExit();
   MessageBox.Show(output[number]);
});
Theodor Zoulias
  • 34,835
  • 7
  • 69
  • 104
  • It's hard to give you an answer besides "run Process.Start three times". Can you [edit] your post with what you've tried so far - such as a [mre]. – gunr2171 Aug 19 '22 at 12:46
  • I have added the code see above. – Roadrunner Aug 19 '22 at 12:52
  • Possibly related: [Get return value of method in parallel execution](https://stackoverflow.com/questions/29211957/get-return-value-of-method-in-parallel-execution), and [Awaiting multiple Tasks with different results](https://stackoverflow.com/questions/17197699/awaiting-multiple-tasks-with-different-results). – Theodor Zoulias Aug 19 '22 at 12:52

0 Answers0