Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: close process on app's process' killing (with taskman)

I'm very new to C# so my question may sound rediculous. I'm developing an application which sometimes need to run ffmpeg. As you guess, this ffmpeg process must be killed when it's host app was closed. I use such code for this task:

AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
private void OnProcessExit(object sender, EventArgs e)
   {
      proc.Kill();
   }

This works fine, when the app is closed correctly (via it's interface or with Taskman - Applications). The problem is that OnProcessExit event won't trigger, if the program's process was killed (with Taskman - Processes). As far as I know, killing process and closing program actions are not the same on the low level, but I guess, killing process is a command to it and it can be handled with C# tools. So, is it possible, to close child process in this case?

like image 480
JustLogin Avatar asked Apr 15 '13 13:04

JustLogin


1 Answers

I think Try this

Application.Exit();
like image 53
Kushal Patil Avatar answered Oct 09 '22 17:10

Kushal Patil