Hi, I wrote a windows service using C# and it runs fine. However every time on reboot windows complains that the service hung on startup. After logging into the computer and going to the Services panel I find the service running just fine. Any ideas as to why windows should complain the service hung when it has not? Also if I restart the service again directly from the Services panel I get no such error. Puzzling. Thanks, Dinesh
The control of the SCM to start services is asynchronous. SCM waits only so long for your START event to finish, and return to caller, at which time the framework tells the SCM you are now started. SCM can timeout and give up waiting for you, and then you could actually be finishing a few seconds later. At system startup you may be waiting for a dependent resource, or perhaps just CPU. The .NET framework does not provide a mechanism for you to HINT that you need more time, as does the SDK approach. Therefore you need to find out what is taking so much time in your startup. There are several strategies to deal with this, depending upon what it is. Dinesh wrote: > Hi, > > I wrote a windows service using C# and it runs fine. However every time > on reboot windows complains that the service hung on startup. After > logging into the computer and going to the Services panel I find the > service running just fine. > > Any ideas as to why windows should complain the service hung when it > has not? > > Also if I restart the service again directly from the Services panel I > get no such error. Puzzling. > > Thanks, > Dinesh