Search code examples
c#processexitexit-code

Issue with Process Exited


lets say I have a process with the ID 1234. This process is running before my application runs.

I have this code:

        Process app = Process.GetProcessById(1234);
        MessageBox.Show(app.MainWindowTitle);
        app.Exited += this.methodShowsMessageBox;

Now, when I compile and run the app, it gets the process and shows the main window title. However when i close process 1234, the app.Exited does nto fire... why is this? And how would i get it to fire?


Solution

  • Please note that the documentation states that EnableRaisingEvents must be set to true before this event will fire.