From Newsgroup: alt.comp.os.windows-11
T <
T@invalid.invalid> wrote:
W11-25H2 V2
I was working a a task that a customer wanted run
from the Task Scheduler. Every time I tested
is said "running". It should have exited almost
instantly.
I tore my hair out trying to figure out why is never
exited. Turns out, all I had to do was press "F5"
to refresh the Task Scheduler screen. My code way
fine!
After running a scheduled task, Task Scheduler does not automatically
refresh its display nor refresh when status of a task changes. You run
a task, refresh, and then check status.
menu: Action -> Refresh
Actions panel -> Refresh
F5 also works.
Commands to services are asynchronous: Task Scheduler, or sc.exe, issue
the command, but there is no response from the service for the Task
Scheduler to trigger upon to know the service's state has changed. When
Task Scheduler issues a state change, it doesn't wait and report a state change, because service didn't report the state change hence Task
Scheduler (or sc.exe, the service controller) are asynchronous to the
effect of the commands they sent to the services. That's why you have
to be careful when bringing up some services that you do so in the
correct order, and refresh to see when the dependent services are ready.
The services do not issue a semaphore or signal when they've changed
state. The Task Manager won't know until it polls the service, and
that's done on a refresh.
Been that way for a very long time. Probably back through all NT-based versions of Windows. Commands are asychronous to the service state.
--- Synchronet 3.21f-Linux NewsLink 1.2