September 17th, 2015

How can I start my service as soon as possible, before any other service?

A customer wanted to know how they could make their service start before any other service.

FIRST!

Of course, a simple application of the What if two programs did this? principle shows that this is not possible.

Upon closer questioning, the real problem was that they had a service which configured some piece of hardware, and they wanted to make sure this configuration was completed before starting the service that uses the hardware. “But we don’t want to create a dependency between the two services.”

Okay, so first of all, they didn’t actually want to be FRIST. They merely wanted to come ahead of the other service. And the way to do that is to create a service dependency so that the other service depends on their custom service. But then they added a remark where they pre-emptively rejected the solution to their problem.

The way to control the order in which services start up is to create dependencies among them. Rejecting the correct solution only leads you down the path to creating incorrect solutions. And incorrect solutions tend to create all sorts of problems.

So do the right thing. Create the service dependency.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.