title: How to create a System.Diagnostics.Process array
body: <p>I want to call three of the same EXE at the same time, and I expect three return value when they all terminated, Here's how I got so far:</p>
  
  <pre><code>    System.Diagnostics.Process p = new System.Diagnostics.Process();
      p.StartInfo.FileName = MyEXEPath;
      for(int i=0;i&lt;3;i++)
      {
         p.StartInfo.Arguments =  para1[i] + " " + para2[i];
         p.Start();
         Console.WriteLine("Start run");
      }
      p.WaitForExit();
      int result = p.ExitCode;
      Console.WriteLine("Return info:" + results);  //Problem: I can only get the last return value
  </code></pre>
  
  <p>You can see I only got one return value, not three, so I wonder if I can do this:</p>
  
  <pre><code>    int[] results = new int[3];
      System.Diagnostics.Process p[] = new System.Diagnostics.Process()[3];
      for(int i=0;i&lt;3;i++)
      {
         p[i].StartInfo.FileName = MyEXEPath;
         p[i].StartInfo.Arguments = para1[i] + " " + para2[i];
         p[i].Start();
         Console.WriteLine("Start run");
         p[i].EnableRaisingEvents = true;
         p[i].Exited += (sender, e) =&gt;
         {
            results[i] = p[i].ExitCode;
            Console.WriteLine("Return info:" + results[i]);
         };
      }
      while(results[0] != 0 &amp;&amp; results[1] != 0 &amp;&amp; results[2] != 0 )
      {
          break;  //all EXEs ternimated,  break and continue my job
      }
  </code></pre>
  
  <p>Sure it is compile fail with <code>System.Diagnostics.Process p[] = new System.Diagnostics.Process()[3];</code>
  So how can I fixed it or there's another way?</p>