i am facing problem during starting my window service... as there is a big load on OnStart() event of my service, it scrap data, saved it to database and send email. So my service need to increase start time because the defualt timeout is 30second... i have released that my service will need additional time to start when i face the following exception..
"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."
Plz help me... Thanx in advance
Have you considered using task paraller library for this. This example is VB.Net but you get the idea:
to debug the OnStart of service (it can be a "long running task"), i use this:
As far as I know that hard limit is there exactly to prevent this sort of abusive behavior from services :)
Make your long running tasks run outside the startup of the service. Handle stopping the service gracefully, then you can automatically stop the service when it's done if you need to. There's no need to do everything on startup.
You better do your long operations in a Thread.
doing long runnings tasks on constructor/start isn't good. you should start your long running task on a sperate thread.
Service startup should be instant and should not hang up.
However if you still want, you can do this
From MSDN