Windows Service execute logic after OnStart -


i have windows service has several timer jobs in it. in onstart method, starting timers. in effect, takes lot of time starting service services console , of time, reports this: windows not start 'servicename' service on local computer. service did not repond start or control request in timely fashion.

i know create timer encapsulatesthe other timers start them outside onstart event. however, i'm looking other possible solutions don't idea of having separate timer nothing other start other processes.

it isn't safe perform external operations such web or database calls during onstart, because can't predict how long take, , an excessively long service startup time can interfere system:

the service control manager (scm) waits until service reports status of service_running. recommended service reports status possible, other components in system require interaction scm blocked during time. functions may require interaction scm either directly or indirectly.

so proper solution move initialization separate thread.

however, if don't want this, can call requestadditionaltime:

the requestadditionaltime method intended called overridden oncontinue, onpause, onstart, or onstop methods request additional time pending operation, prevent service control manager (scm) marking service not responding.


Comments