using System.Diagnostics;
Result results = new Result();
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = false;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
do {
results = RunHeavyOperation(results);
cmd.StandardInput.WriteLine("echo " + results.usefulInfo);
} while (!results.conditionForEnd);
cmd.WaitForExit();
Result RunHeavyOperation(Result previousResults) {
Result res = doHeavyStuff(previousResults);
return res;
}
我意识到我缺少一部分,但是它是什么?
System.Diagnostics.Debug.Write(results.usefulInformation);
解决了这个问题,但如果应用程序进入生产环境,这种方法就不可行了。 - Toivo Säwén