.net - Process.Kill 后是否需要使用 Process.WaitForExit?

标签 .net process kill-process

Process.Kill 后是否需要使用 Process.WaitForExit?
如果调用进程在调用 Process.Kill 后立即退出怎么办?
这会导致 Process.Kill 失败吗?

编辑:我需要在退出我的应用程序时终止一个进程。在这一点上,我不打算处理 kill 失败的情况,因此我没有必要等待进程退出。因此,如果不需要调用 WaitForExit,我可以跳过它。

最佳答案

根据documentation on MSDN (强调我的)

Note The Kill method executes asynchronously. After calling the Kill method, call the WaitForExit method to wait for the process to exit, or check the HasExited property to determine if the process has exited.



如果你不需要等待,或者如果你不需要确定进程是否真的存在,那么我想你不需要调用WaitForExit或查看 HasExited .

关于.net - Process.Kill 后是否需要使用 Process.WaitForExit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7078440/

相关文章:

c# - 在 IronPython 中使用 C# 代码

linux - 在 Linux 中,当一个进程即将被交换或终止时,它的线程应该处于什么状态?

node.js - 从命令行向 Node.js 脚本发送字符串和回车键

internet-explorer - 如何从批处理文件打开和关闭 Internet Explorer?

java - 如果进程在外部被杀死则处理

c# - 返回 IEnumerable 和调用 ToArray 时的 LINQ 意外行为

.net - 有没有可以模拟静态方法和密封类的免费模拟框架?

c# - Google Pay 通行证

algorithm - 使用什么算法来格式化 EDIFACT 文件?

oracle - 如何在 Oracle 12c (12.2.0.1.0) 中处理 ORA-00028 "your session has been killed"?