C# 暂停/停止 System.Diagnostics.Process [英] C# Pause/Stop System.Diagnostics.Process
本文介绍了C# 暂停/停止 System.Diagnostics.Process的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个运行 exe 的进程:
I have a Process that runs an exe:
Process pr = new Process();
pr.StartInfo.FileName = @"wput.exe";
等
我希望能够暂停和停止此进程.有没有我可以提出的事件来实现这一目标.我有多个进程在我的应用程序中工作,每个进程都有自己的线程.我看着暂停线程,但这不会给我想要的结果.
I want to be able to pause and stop this Process. Are there any events I can raise to achieve this. I have multiple Processes working in my app, each with it's own Thread. I looked at pausing Threads but that would not give me the result I want.
推荐答案
您可以像任务管理器一样读取系统中的进程列表,并尝试终止名为wput.exe"的进程.
You could read the list of processes in the system, as task manager does and try to kill the process with the name "wput.exe".
试试这个
using System.Diagnostics;
private void KillAllProcesses( string name )
{
Process[] processes = Process.GetProcessesByName( name );
foreach( Process p in processes )
p.Kill();
}
这篇关于C# 暂停/停止 System.Diagnostics.Process的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文