Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Starting a service once you've installed it

Status
Not open for further replies.

dpursifull

Programmer
Sep 15, 2003
7
US
Hi,

I've created a service in .Net and installed it on my local machine successfully. Whenever I open up the services and attempt to start it I get the following error:

"The service did not respond to the start or control request in a timely fashion."

Then of course it does not start. Has anyone encountered this error before?

Thanks,

Dena
 
Dena,
I see you got no answer to this dilemma. Well I am encountering a similar problem but my service is starting. I just can't stop it in the typical fashion but the code is executing just fine. Did you ever find an answer to this problem?
 
Sounds like permissions. Have you checked what security context it is running under?

i.e. Control Panel or Admin Tools (depending on OS)
services -> Your service-> Right Click ->Properties-> Log On->Log On as:
 
I figured it out. I am making a call to a "by design" almost infinite loop from within the Onstart procedure. I found documentation saying that code in that routine must complete within 10 seconds or that error will occur. I am searching for code that will allow me to create a new thread to run the loop on so control can pass back to the OnStart routine.
 
Ok - for future seekers - here is the solution

Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.

EventLog.WriteEntry("A2AService", "Service Started", EventLogEntryType.Information)

bShutDownRequested = False
dim loopThread as Thread
loopThread = New Thread(AddressOf StartLoop)
loopThread.Start()

End Sub

Startloop is the name of the procedure where I fire off the infinite looping process (until service is requested to stop - at which point bShutDownRequested is set to True which halts the loop and the thread - which ends up finishing after the service is stopped.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top