How can I wait until all startup applications have finished launching?

Raymond Chen

Raymond

A customer wanted to know how to detect that all startup applications have finished launching. They wanted to wait until everything settled down before proceeding with some task.
What if two programs did this?
Suppose two programs both wanted to detect that all startup applications have finished launching. Each one would sit there waiting for the other, because this is one of those I want to be the last to do something, even laster than the other guy who wants to do something last things.

If you want to wait until the system is idle to perform some task, you can use the Task Scheduler to create an idle-time task. This has the benefit of coordinating multiple idle-time tasks so that you don’t have the phenomenon of two applications both trying to do things when they think nobody else is doing anything, resulting in an Alphonse-and-Gaston state: The system goes idle, and both Alphonse and Gaston start doing their idle-time tasks. But Alphonse notices that Gaston is busy and backs off; at the same time, Gaston notices that Alphonse is busy and backs off. Now the system is idle again, and both Alphonse and Gaston start their idle-time tasks, and the cycle continues. The computer gets into this weird state where it keeps waking up, going to sleep, waking up, going to sleep, and never actually making progress.

Raymond Chen
Raymond Chen

Follow Raymond