读书人

System.Diagnostics.Process 运行完需

发布时间: 2012-05-04 12:36:09 作者: rapoo

System.Diagnostics.Process 运行完需要按一个键 不然程序就挂起了..
我在控制台程序里调用了另一个控制台程序(不是我自己写的 print2flash3)
print2flash执行完了会

无论是设置地不显示窗口还是隐藏模式什么的, 最终程序都会被挂起, 就像这样
我要不按个键, 我的程序就被停在这了!


按了键以后我的程序就运行成功了






System.Diagnostics.Process pss = new System.Diagnostics.Process();
try
{
pss.StartInfo.CreateNoWindow = true;
pss.StartInfo.FileName = app;
pss.StartInfo.Arguments = string.Format("{0} {1}",sourcePath, swfPath);
pss.Start();

while (!pss.HasExited)
{
continue;
}

}
catch (Exception ex)
{
return false;
}
finally
{
pss.Close();
pss.Dispose();
}

[解决办法]
碉堡了,这都用



while (!pss.HasExited)
{
continue;
}
----------------------------------------

他等你按键

var standartInput = pss.StandardInput;
standartInput.AutoFlush = true;
standartInput.WriteLine("y");
standartInput.Close();



读书人网 >C#

热点推荐