I followed the instructions in the marked answer here to create a service. The service gets installed correctly. When I start the service after a while it throws a message "Windows could not start the xxx service on Local Computer.
Error 1053: The service did not respond to the start or control request in a timely fashion. "
After I click ok, its status stays at "Starting" for ever. When I checked the application and system logs, there were no errors.
When I check the SQL trace, the service is actually running correctly and doing what its supposed to do. So why does its status stay at "Starting" ?
Update: This is the code in OnStart method
protected override void OnStart(string[] args)
{
Loader loader = new Loader();
loader.StartProcess();
}
Update 2:
based on WiktorZychla's comment I did this and it worked :)
protected override void OnStart(string[] args)
{
Loader loader = new Loader();
ThreadStart threadDelegate = new ThreadStart(loader.StartProcess);
Thread newThread = new Thread(threadDelegate);
newThread.Start();
}
loader.StartProcess
never returns, you have what you see. In OnStart you should rather start a new thread and the method should return just after. – Wiktor Zychla