我有一份窗口申请书,在单册中书写。
Everything is working except one problem. When the perl script run, it runs as a process launch by c# application. There are some delays I put in the perl script to wait for messages from socket interface.
Because of those delays, when c# application runs the script, the GUI looks like not responding state. I was using Process class to run the script. My question is that is there way to gives control back to parent process, the c# application from perl script process?
I thought the process.start() in c# is forking a new process, which shouldn t affect the GUI or the c# application itself.
Here is my code to start the perl script: loop through all perl scripts... { Process myProcess = new Process(); 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);
As you can see, I used to put the Text Box appending code inside the loop. I expected that i can get updated immediately. But now, with the delay, the GUI is not responding I have to update the text box after process exit. Is there a way to solve this problem?
得到帮助。