如何从Web应用程序跟踪控制台应用程序状态?

时间:2018-02-05 13:31:13

标签: c# asp.net asp.net-mvc visual-studio console-application

我创建了一个运行一些python脚本的控制台应用程序。控制台应用程序的输出是两个文件将在目标创建,我从我的Web应用程序调用此控制台应用程序。我在从网上跟踪控制台应用程序状态时遇到了问题。

控制台应用程序代码:

Process process = new Process();
sortOutput = new StringBuilder("");
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.WorkingDirectory = @"C:\TensorFlow\tensorflow-for-poets-2";
process.ErrorDataReceived += new DataReceivedEventHandler(CaptureError);
process.OutputDataReceived += new DataReceivedEventHandler(MyProcOutputHandler);
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.StandardInput.WriteLine("set IMAGE_SIZE=224");
process.StandardInput.WriteLine("set ARCHITECTURE=\"mobilenet_0.50_%IMAGE_SIZE%\"");
process.StandardInput.WriteLine(@"python -m scripts.retrain \ --bottleneck_dir=tf_files/bottlenecks \ --how_many_training_steps=500 \ --model_dir=tf_files/models/ \ --summaries_dir=tf_files/training_summaries/%ARCHITECTURE% \ --output_graph=tf_files/retrained_graph.pb \ --output_labels=tf_files/retrained_labels.txt \ --architecture=%ARCHITECTURE% \ --image_dir=tf_files/flower_photos");
process.StandardInput.Flush();
process.StandardInput.Dispose();

网络应用程序:

Process process = new Process();
process.StartInfo.FileName = 
Server.MapPath("~/Content/ConsoleApp1.exe");
process.Start();
Label1.Text = "done";

在后台,而控制台应用程序正在进行Web应用程序显示完成..

0 个答案:

没有答案