'C# Thread.Start forced to wait because of Process.WaitForExit()

This is a hard one to explain, but I'm sure something is operating as intended.

Basically, I am starting a new Thread like so

for (int i = 0; i < something.Length; i++)
{
    Thread t = new Thread(newT => new Execute(args));
    t.Start();
}

Inside of Execute I have the following,

Process proc = new Process
{
    StartInfo = new ProcessStartInfo(commandline)
};
proc.StartInfo.Arguments = string.Format(args);
string output = proc.StandardOutput.ReadToEnd();
string err = proc.StandardError.ReadToEnd();
proc.WaitForExit();

I'm expecting the for loop to continuously fire, so lets say I have 10 objects I just want to to fire over those 10 immediately. However, because of the proc.WaitForExit() the thread waits for the exit to continue the for loop.

What can I do, to keep the for loop going? I need each thread to wait for the exit without holding up the for loop



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source