user6667032 user6667032 - 1 year ago 133
C# Question

C#: Working with seperate .exe

I have a complex console program for data manipulation that's a pain to use.

I'm trying to create a wrapper type GUI program to facilitate ease of use.

Right now I'm opening a new thread and using Process.Start() and capturing the output.

This works great except for one issue, how do I cancel the process on demand from the user?

Given the fact the process is CPU intensive and can have long run times this is very important.

Answer Source

Use the Process.Kill() method:

foreach (var process in Process.GetProcessesByName("whatever"))

If you don't want to kill all the instances of whatever then start your process using:

process = Process.Start("whatever");

Then call the Kill method when you want to:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download