I am interested to know how does task scheduler ends a running task.
I have added an app to the task scheduler jobs, and it seams like when pressing end in Task Scheduler for my job (after starting it from task scheduler), the task is killed by windows (didn't receive WM_QUIT
or WM_CLOSE
messages in my app). I also didn't find a way to configure how I want my task to be closed in Task Scheduler.
My goal is to treat the message that is send by Task Scheduler (if any) and close my app nicely.
Probably the process is killed with the Windows function TerminateProcess()
. The message queue has nothing to do with it. There is no way to configure this and there's no way to trap TerminateProcess.
If you need to run for long periods of time, consider creating a real Windows service instead of using Task Scheduler. Then you will get Service Control Notifications, including notifications for shutdown, which allow you to clean up before your service exits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With