2

Basically I have my "monitor" and I'm playing and the executable is "Game.exe" (Rpg Maker xp). I want my "monitor" to close itself after Game.exe is killed or terminated. If I can, how should I do this properly? Sorry horrible english

Heinzi
  • 167,459
  • 57
  • 363
  • 519
Paulo
  • 37
  • 3
  • 1
    [Detect closing of the other process](http://stackoverflow.com/questions/39703399/how-to-know-if-external-winform-was-closed), then [exit the application](https://msdn.microsoft.com/en-us/library/system.windows.forms.application.exit(v=vs.110).aspx). – Reza Aghaei Sep 26 '16 at 19:39

1 Answers1

1

You can use Process.GetProcessesByName to find out whether your "target process" is still running:

Dim gameStillRunning = Process.GetProcessesByName("Game").Any()

How to trigger the end of your own application depends on the nature of your monitoring application:

  • If it's a GUI application, set a timer that frequently checks if Game is still running.

  • If your application has no other purpose than to wait until Game has been closed (or if you have a dedicated thread for this purpose), you can use p.WaitForExit() on the process p obtained by GetProcessesByName.

Heinzi
  • 167,459
  • 57
  • 363
  • 519