简体   繁体   中英

How does Task Scheduler ends a running job?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM