Process.Close()不终止创建过程中,C# [英] Process.Close() is not terminating created process,c#
问题描述
我写的,它使用的System.Diagnostics.Process类来创建过程中,采用C#应用程序
I've written a C# application which uses System.Diagnostics.Process class to create a process, using
Process P1 = new Process();
P1.FileName = "myexe.exe";
和其他适当的设置。
我就链接到它运行约10分钟,一个exe文件。 (我在写程序的程序运行时的测量仪)。现在我之间要中止正在运行的进程。所以我在取消按钮的事件中写道,
I've linked it to an exe file which runs for about 10 minutes. (I'm writing program to measurer runtime of programs). Now in between i want to abort the running process. So I wrote in the cancel button's event,
Process.Close();
但在任务管理器我仍然看到MYEXE.EXE运行,它不会中止。怎么办?
But in the task manager i still see myexe.exe running, it doesn't get aborted. What to do?
推荐答案
<一个href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.process.close.aspx\">Process.Close()并不意味着中止该过程 - 它只是为了释放过程中的本地视图和相关资源
Process.Close() isn't meant to abort the process - it's just meant to release your "local" view on the process, and associated resources.
我想你的意思<一个href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.process.kill.aspx\">Process.Kill()或<一个href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.process.closemainwindow.aspx\">Process.CloseMainWindow().个人而言,我会设法找到它关闭,虽然一个更优雅的方式。
I think you mean Process.Kill() or Process.CloseMainWindow(). Personally I'd try to find a more graceful way of shutting it down though.
这篇关于Process.Close()不终止创建过程中,C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!