终止进程
我有一个如下所示的流程对象设置:(
Process p = new Process();
p.StartInfo.FileName = command;
p.StartInfo.UseShellExecute = true;
p.StartInfo.Arguments = String.Format(
commandArguments,
destinationLocation,
sourceLocation,
sourceDirName,
(string.IsNullOrEmpty(revisionNotes.Text)) ? "" : revisionNotes.Text);
其中未定义的值从外部提供给此代码并且有效)。有问题的进程使用 p.Start();
启动并正确执行,但我需要在终止时捕获它。控制台窗口短暂闪烁然后消失,这似乎表明该过程已完成,但没有触发任何相关事件(OutputDataRecieved、Exited 等),并且该过程就像永远不会结束。 (我正在尝试使用一些相关参数执行 lua 脚本)。有人可以帮助我正确停止这个过程吗?
I have a process object setup like the following:
Process p = new Process();
p.StartInfo.FileName = command;
p.StartInfo.UseShellExecute = true;
p.StartInfo.Arguments = String.Format(
commandArguments,
destinationLocation,
sourceLocation,
sourceDirName,
(string.IsNullOrEmpty(revisionNotes.Text)) ? "" : revisionNotes.Text);
(where undefined values are supplied externally to this code and are valid). The process in question launches and properly executes with p.Start();
but i need to catch it on termination. The console window flashes up briefly and goes away which would seem to indicate that the process is done, but none of the relevant events are fired (OutputDataRecieved, Exited, etc) and it's like the process never ends. (I'm trying to execute a lua script with some parameters if that's relevant). Can someone help me get this process to stop correctly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
等待退出
WaitForExit
您是否设置了 EnableRaisingEvents 属性过程为真?如果没有它,您将无法捕获 Exited 事件。
Have you set the EnableRaisingEvents property of the process to True? You won't catch the Exited event without it.