I just need to detect when my WPF application is killed from "Task Manager" --> "Process" tab, not from "Application" tab.
again mentioning just need to detect not stop or intercepting!
a piece of C# code would do fine.
I just need to detect when my WPF application is killed from "Task Manager" --> "Process" tab, not from "Application" tab.
again mentioning just need to detect not stop or intercepting!
a piece of C# code would do fine.
As @DavidHeffernan already told you you have to use another process/service that will check for your process termination using one of the techniques from How to detect win32 process creation/termination in c++.
You will just have to properly reinitialize this process/service while starting your actual application.
But how to understand that your process has been terminated forcefully and has not been peacefully closed?
TerminateProcess is the low-level process killing function. It bypasses DLL_PROCESS_DETACH and anything else in the process. Once you kill with TerminateProcess, no more user-mode code will run in that process. It’s gone. Do not pass go. Do not collect $200.
WM_CLOSE
message). Then the service checks whether that directory exists or not (some race condition is actually possible if your application is restarted before service checks the indicator directory)P.S.: In any case you will have to carefully consider the management of the service that will watch for your application. Race conditions and other nasty things can occur. Especially if your application can be launched in multiple instances.