Detect when specific program program has closed with C#

Viewed 142

I have two different .jar programs running on the same machine. I want to be able to detect when one of them has been closed, or is no longer running.

This issue that I am having is, when running this code:

  var allProc = Process.GetProcesses();
  foreach (var p in allProc)

  comboBox1.Items.Add(p.ProcessName);
  comboBox1.Sorted = true;

It only shows a single instance of Java running, and not only that it doesn't show either of the process names.

The program I want to monitor uses a lot of RAM, so I thought about monitoring RAM usage and doing what I need when it drops below a certain level, but to me that sounds like a hacky way of doing it and other factors could effect it.

Any ideas?

3 Answers
Related