【发布时间】:2011-01-14 09:37:56
【问题描述】:
我有一个控制台应用程序并在 Main 方法中。我像下面的代码一样启动一个进程,当进程存在时,该进程的 Exist 事件被触发,但它也关闭了我的控制台应用程序,我只想启动一个进程,然后在该进程的退出事件中启动另一个进程。
进程输出也反映在我的主控制台应用程序中。
Process newCrawler = new Process();
newCrawler.StartInfo = new ProcessStartInfo();
newCrawler.StartInfo.FileName = configSection.CrawlerPath;
newCrawler.EnableRaisingEvents = true;
newCrawler.Exited += new EventHandler(newCrawler_Exited);
newCrawler.StartInfo.Arguments = "someArg";
newCrawler.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
newCrawler.StartInfo.UseShellExecute = false;
newCrawler.Start();
【问题讨论】:
标签: c# .net process console-application