Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Process.exited doesnt get called until after window is closed

So I am writing an application that monitors a console application that was written by another developer. The console application is prone to crashing and because it runs all night i need my application to restart it.

Unfortunaltey when the console app crashes i get the windows message that says "blah has stopped working" And a button that says close program.

I am using System.Diagnostic.Process to start the console application but I cannot determine if the console application has crashed until AFTER the close program button is hit. Process.Responding is always true (there is no windows handle) Process.exited isnt fired till after the close program button is hit.

Any ideas would be greatly helpfull.

Thanks

like image 895
user1253149 Avatar asked Oct 09 '22 11:10

user1253149


1 Answers

Disable the windows crash reporting feature. It gets notified by the kernel when a process fails. The process is alive until the crash reporting thingy is done with it.

The feature can be disabled per-process using some API. Disabling Windows error reporting (Dr. Watson) for my process Don't globally disable it to fix a local problem.

like image 198
usr Avatar answered Oct 12 '22 16:10

usr