I have a windows service implemented in C# that works fine unless there's an extra-long startup. Specifically, after we create a local account on a workgroup computer (running Windows Server 2016), configure it for automatic logon, and restart the
computer.
In this scenario, the logon window lingers at the "Please wait for the ProfSvc" for several minutes. After the box finally comes up, three services dependent on mine fail to start, even though my service eventually does.
Looking at the event viewer log, the SCM thinks my service has hung (about 3:30 after boot), but it hasn't even told it to start yet (about 8:30 after boot)! I know a service has to start in a timely fashion or call SetServiceStatus with an appropriate wait
hint, but I never even get the chance.
What's going on here?
Event Viewer timeline:
0:00 Kernel-General12
The operating system started
3:32 Service Control Manager 7022
[My Service] hung on starting.
3:32 Service Control Manager 7001
The [Foo] service depends on [My Service] which failed to start because of the following error:
After starting, the service hung in a start-pending state.
3:32 Service Control Manager 7022
[My Service] hung on starting.
3:32 Service Control Manager 7001
The [Bar] service depends on [My Service] which failed to start because of the following error:
After starting, the service hung in a start-pending state.
3:32 Service Control Manager 7022
[My Service] hung on starting.
3:32 Service Control Manager 7001
The [Eeber] service depends on [My Service] which failed to start because of the following error:
After starting, the service hung in a start-pending state.
8:34 [My Service] 0
OnStart() called
11:42 [My Service] 0
Service started successfully.
11:42 Service Control Manager 7036
[My Service] entered the running state.