Unity Editor freezes when starting several System.Diagnostics.Process one after another
I have got a method that starts an external process via System.Diagnostics.Process and returns its output as a string:
 public static string ExecuteCommand(string command, string[] arguments)
 {
     var processInfo = new System.Diagnostics.ProcessStartInfo(command, string.Join(" ", arguments));
     processInfo.CreateNoWindow = true;
     processInfo.RedirectStandardOutput = true;
     processInfo.UseShellExecute = false;
 
     string output = "";
     var process = System.Diagnostics.Process.Start(processInfo);
 
     while (!process.StandardOutput.EndOfStream)
         output += process.StandardOutput.ReadLine() + "\n";
 
     process.WaitForExit();
     process.Close();
 
     Debug.Log(output);
     return output;
 }
Which works fine, the editor is frozen while the command is being executed which is expected using the process.WaitForExit() flag, however I noticed that when calling this function multiple times, the editor stays frozen until the last command has finished executing. So, if I have:
 ExecuteCommand("adb", "install test.apk")
 Debug.Log("A")
 ExecuteCommand("adb", "uninstall com.app.test")
 Debug.Log("B")
 ExecuteCommand("adb", "push file.mp4")
 Debug.Log("C")
A, B and C won't be printed until the last command (adb push) has finished execution. I can understand the ExecuteCommand method is blocking but shouldn't control being given back to the Unity Editor once it's finished and letting print the debug messages inbetween calls?
How could I fix this? Can't use coroutines because it's an EditorWindow script.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                