I have deployed my windows service (using independently installer class and SC.EXE), but I get an error when I try to start it:
---------------------------
Services
---------------------------
Could not start the MyName service on Local Computer.
Error 1053: The service did not respond to the start or control request in a timely fashion.
What is the timeout? It felt like around 3 secs. What do I need to do if my service takes longer?
In regards to the specific question, the exact timeout varies, but is less than 30 seconds. You can control the default startup timeout for a service via a registry key, you can see how to do this here.
However, I will agree with many others that I would look at two possible options.
Also if you had tested the service in different Physical environments, and it seems that the issue is not the normal startup time but the performance of the PCs. You can increase the timeout on the registry key for the specific PC.
Please see: http://support.microsoft.com/kb/839803
Regards
The normal way of creating a service is to have the startup code create a new thread, and run your service in that thread.
The service startup should be nearly instantaneous - nothing more than spawning a new thread with your "real" work in it.
If you're taking more than three seconds, that's a sign that you're doing the real work in your main thread, and not creating a separate one for your service.
In your service class, use
ServiceBase.RequestAdditionalTime()
in your OnStart/OnStop method: