나는 C# lauch perl 스크립트로 작성된 윈도우 폼 애플리케이션을 가지고있다.C# 프로세스는 부모 프로세스 질문으로 컨트롤을 돌려 준다.
한 가지 문제 외에는 모든 것이 작동합니다. 펄 스크립트가 실행되면, C# 응용 프로그램에 의해 프로세스 실행으로 실행됩니다. perl 스크립트에 몇 가지 지연이 있습니다. 소켓 인터페이스에서 메시지를 기다리는 중입니다.
지연 때문에 C# 응용 프로그램이 스크립트를 실행할 때 GUI가 응답하지 않는 것처럼 보입니다. Process 클래스를 사용하여 스크립트를 실행하고있었습니다. 내 질문은 부모 프로세스에 다시 제어 할 수있는 방법입니다, 펄 스크립트에서 C# 응용 프로그램 프로세스?
C#의 process.start()가 새로운 프로세스를 포크 화한다고 생각하여 GUI 또는 C# 응용 프로그램 자체에 영향을 미치지 않아야합니다. 여기
는 펄 스크립트 시작하는 내 코드입니다 : 모든 펄 스크립트를 통해 루프 ... { 프로세스 myProcess = 새 프로세스(); MessageBox.Show ((string) curScriptFileName); string ParentPath = findParentPath((string)curScriptFileName);
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("perl.exe");
myProcessStartInfo.Arguments = (string)(curScriptFileName);
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
myProcessStartInfo.CreateNoWindow = true;
myProcessStartInfo.WorkingDirectory = ParentPath;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
// Read the standard output of the spawned process.
output = myProcess.StandardOutput.ReadToEnd();
//MessageBox.Show(output);
//this.ScriptTestResultTextBox.AppendText(output);
//Console.WriteLine(output);
myProcess.WaitForExit();
}
this.ScriptTestResultTextBox.AppendText(output);
이전과 같이 루프 안에 텍스트 상자 추가 코드를 넣었습니다. 나는 을 즉시 업데이트 할 수있을 것으로 예상했다. 그러나 지연과 함께 GUI가 응답하지 않습니다. 프로세스 종료 후 텍스트 상자를 업데이트해야합니다. 이 문제를 해결할 방법이 있습니까?
도움 주셔서 감사합니다.
[이 게시물 (http://www.codeducky.org/process-handling-net)]은 .NET 프로세스 작업의 많은 복잡한 부분을 다루고 있습니다. 특히 입력 및 출력 작업 . [MedallionShell] (https://github.com/madelson/MedallionShell) 라이브러리를 권장합니다.이 라이브러리는 프로세스 스트림 처리를 단순화합니다. – ChaseMedallion