Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Task scheduler's kill message, which one?
Message
De
06/03/2015 16:19:02
 
 
À
06/03/2015 15:31:34
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Installation et configuration
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2003
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01616357
Message ID:
01616378
Vues:
26
>>>I have a little exe which needs to monitor a certain resource. To make sure it's always on, I run it via task scheduler (so far so good, that works), however just in case it may get stuck, I want to recycle it. So I've set the task scheduler to stop the existing instance if it's already running. That doesn't work.
>>>
>>>The exe has practically no GUI, save for a toolbar with an exit button, and it sits in infinite Read Events state. The exit button works fine - deletes the objects, executes a Clear Events and the app exits gracefully.
>>>
>>>However, the task scheduler doesn't kill it. I've set it to run a new instance every 5 minutes (just for testing) and sure enough, after half an hour I have 5-6 of them stacked up. Now I guess I should bindevent() to something, just don't know what. I've tried _screen's QueryUnload() - doesn't fire (not even when I click the closebox manually). Tried _screeen.hwnd with wm_close, wm_quit and wm_destroy, doesn't fire.
>>
>>Fix your EXE so it doesn't get stuck ;) Only half joking, if you can do that a lot of cruft goes away.
>
>It doesn't. But Justin Case is my friend.
>
>>Otherwise maybe something like http://www.sevenforums.com/general-discussion/224903-how-close-exit-some-program-using-task-scheduler-windows-7-a.html ?
>
>That's more complicated, also what Hugo said - involves more files, more setup.
>
>Well, since this is already running on a timer, I'll check seconds() at start and on timer, and if over the specified interval, seppuku.
>
>But I'd really want to know which message am I getting from Windows when task scheduler tries to close, and why I can't bind to _screen.queryunload()...

Dunno about seppuku - in general you can't have a watchdog in the process you want to watch. If it sticks, so does the watchdog. For example, if you're using a VFP timer, I understand there are some circumstances where it doesn't fire.

In that case you're looking at some sort of launcher/watchdog process as Hugo suggests. Although, that begs the question, who's watching the watcher... ;)

If you go the launcher route, depending on how you're doing your monitoring you might have another approach available:

Approach 1: monitoring EXE ( mEXE ) running all the time, uses timer to perform monitoring action once per minute. Concern: mEXE may get stuck

Alternate approach: Launcher launches mEXE once per minute. mEXE does not hang around, it performs the monitoring action once, then terminates. Probably less chance of getting stuck

This alternate approach won't be useful if mEXE binds to something and waits for external events.

As for your other shutdown attempts not working:

- Are Task Scheduler and mEXE running in the same context i.e. a logged-in user session?

- Have you set your scheduled task(s) to run with elevated privileges?

- Dunno if it would have an effect, but is it possible you've set SYS( 2340 ) to 1 instead of the default 0?
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform