tags:

views:

41

answers:

3

I have a Process that runs an exe:

Process pr = new Process();                                                 
pr.StartInfo.FileName = @"wput.exe"; 

etc

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.

A: 

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".

Try this

using System.Diagnostics;


private void KillAllProcesses( string name )
{
    Process[] processes = Process.GetProcessesByName( name );
    foreach( Process p in processes )
        p.Kill();
}
netadictos
A: 

To kill just started process use:

pr.Kill();

pr.WaitForExit();
// now you sure that it has been terminated
abatishchev
A: 

Pausing of a process started from Process.Start is not possible but you can kill the process.

saurabh