2014-07-12 2 views
-1

여기에서 얻은 단어는 다음과 같습니다. ProcessStartInfo hanging on "WaitForExit"? Why? 실행 프로세스를 만들고 StandardOutput 및 StandardError를 가져 오려면 다음을 수행하십시오. 문제는 여전히 정지 상태입니다. 나는 그것이 cmd를 사용하고 있기 때문일 수 있다고 생각한다. "noJava"는 내 코드에서 실제로 .class 파일에 대한 Filepath이며, 명령을 인쇄하여 단일 서버로 보냅니다. 내가 cmd를 수동으로 호출 할 경우 java -cp E:/Java/src/ Lift을 cmd에 입력하면 코드의 첫 번째 줄을받습니다 : Command: objects["Door"].transform.position.x += ((new Vector3(0.0,1.0,0.0))).x*0.6;objects["Door"].transform.position.y += ((new Vector3(0.0,1.0,0.0))).y*0.6;objects["Door"].transform.position.z += ((new Vector3(0.0,1.0,0.0))).z*0.6; 그리고 단 하나의 창으로 전환하면 나머지 메시지가 나타납니다 (서버가 연결을 수락하는 동안 화합은 활성 창). 나는 이런 식으로 일을하려고하는 경우 은 이제 중단 : 지금 2 일 동안이 문제를 해결하려고했지만 그것이 작동되도록 할 수 없습니다 있습니다StandardError 및 StandardOutput에서 읽기가 응답하지 않습니다.

using (run_process = new Process()) 
     { 
      run_process.StartInfo.FileName = "cmd"; 
      run_process.StartInfo.Arguments = " /C java -cp "+noJava; 
      //run_process.StartInfo.CreateNoWindow = true; 
      run_process.StartInfo.UseShellExecute = false; 
      run_process.StartInfo.RedirectStandardOutput = true; 
      run_process.StartInfo.RedirectStandardError = true; 

     StringBuilder output = new StringBuilder(); 
     StringBuilder error = new StringBuilder(); 

     using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false)) 
      using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false)) 
     { 
      run_process.OutputDataReceived += (sender, e) => { 
       if (e.Data == null) 
       { 
        outputWaitHandle.Set(); 
       } 
       else 
       { 
        output.AppendLine(e.Data); 
       } 
      }; 
      run_process.ErrorDataReceived += (sender, e) => 
      { 
       if (e.Data == null) 
       { 
        errorWaitHandle.Set(); 
       } 
       else 
       { 
        error.AppendLine(e.Data); 
       } 
      }; 

      run_process.Start(); 

      run_process.BeginOutputReadLine(); 
      run_process.BeginErrorReadLine(); 

      if (run_process.WaitForExit(3000) && 
        outputWaitHandle.WaitOne(3000) && 
        errorWaitHandle.WaitOne(3000)) 
      { 
       // Process completed. Check process.ExitCode here. 
      } 
      else 
      { 
       // Timed out. 
      } 
     } 
     } 

. 도와주세요!

+0

활성 창이 아닌 경우 유니티가 일시 중지됩니다. 빌드 된 응용 프로그램으로 시도하십시오 – LearnCocos2D

+0

@ LearnCocos2D 빌드 응용 프로그램을 사용하더라도 작동하지 않습니다 ... 다른 아이디어? – Anton

+0

같은 문제가있는 사람 : 솔루션을 찾은 경우. 문제는 서버가 제대로 종료되지 않도록 상호 작용 한 playmode를 입력 할 때 adb.exe가 시작된다는 것입니다. 버그 링크 : http://forum.unity3d.com/threads/bug-unity-runs-adb-exe-when-entering-play-mode-in-theitor.148176/ – Anton

답변

관련 문제