Article View: borland.public.cppbuilder.nativeapi
Article #16225Re: Abnormal StartService() delays
From: Ted Lyngmo
Date: Wed, 28 May 2003 04:51
Date: Wed, 28 May 2003 04:51
49 lines
3501 bytes
3501 bytes
Remy Lebeau (TeamB) wrote: > When starting one service from within another, does anyone have any ideas as > to what could cause StartService() to take almost 2 full minutes to start > the second service and return control back to the first service, when the > second service only takes a few seconds to initialize itself? > > I have a few services I'm writing which are dependant on another service to > be running, but I can't use actual dependancies because the services > communicate with each other over TCP/IP and the service in question may or > may not be installed on the local machine at all. Thus, the services first > check to see if it is installed locally and if so then start it via > StartService() if needed. I haven't worked with services myself, but I found this in the help: "A service cannot call StartService during initialization. The reason is that the Service Control Manager locks the service control database during initialization, so a call to StartService will block. Once the service reports to the Service Control Manager that it has successfully started, it can call StartService." "The StartService function does not wait [before it returns] for the first status update from the new service (which may take a while)." "The calling process can determine if the new service has finished its initialization by calling the QueryServiceStatus function periodically to query the service's status." Might be worth checking out, even though it sounds like it's not the actual cause (since your second service starts immediately). Maybe there's something in the services being started that is causing this effect? > At least, that's the desired effect, but I'm finding that StartService() can > take unreasonable amounts of time to start even the simpliest of services. > Is there any known issues with calling StartService() from within another > service or what? When starting the simple services from within the control panel, do they start immediately? Do you get the same effect when starting standard Windows services from within your service? Kind regards, Ted Lyngmo -- Replace MY_FIRST_NAME in my email address with my first name to send a private email to me.
Technical Details
Message-ID:
<3ED44056.8080702@lyncon.se>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!newsswitch.lcs.mit.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!wn12feed!worldnet.att.net!216.166.71.14!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3ed4254a$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,d30092022430250a X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-05-27 21:52:21 PST Message-ID: <3ED44056.8080702@lyncon.se> Date: Wed, 28 May 2003 06:51:34 +0200 From: Ted Lyngmo <MY_FIRST_NAME@lyncon.se> Organization: Lyncon - Computer & Music consulting User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1 X-Accept-Language: sv,en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Abnormal StartService() delays References: <3ed4254a$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 217.215.147.98 X-Trace: newsgroups.borland.com 1054097119 217.215.147.98 (27 May 2003 21:45:19 -0700) Lines: 50 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-08!supernews.com!newsswitch.lcs.mit.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!wn12feed!worldnet.att.net!216.166.71.14!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail