Article View: borland.public.cppbuilder.nativeapi
Article #7631Re: Service termination
From: Remy Lebeau (TeamB)
Date: Tue, 18 Jan 2005 07:43
Date: Tue, 18 Jan 2005 07:43
35 lines
2132 bytes
2132 bytes
"Tumurbaatar S." <nospam_tumur@magicnet.mn> wrote in message news:41ec832f@newsgroups.borland.com... > How to stop a service app from the its code? I.e. not in > response of an external request, but a service stops itself. You have a couple of choices: 1) terminate the service's ServiceThread directly 2) call the service's Controller() method to send a SERVICE_CONTROL_STOP request back to the service I prefer #2 myself. It allows the OnStop event to be triggered, whereas #1 does not. > Also, currently all my service initialization code located inside > OnStart event handler and all cleanup code in OnStop one. As well it should be. > Can I use OnCreate/OnDestroy instead them? Never use those events in C++. They are Delphi remnants that can be triggered before/after the constructor/destructor, respectively, which is illegal in C++. Use the actual constructor/destructor instead. In any case, the issue regarding using the constructor/destructor vs. the OnStart/OnStop events depends on what you are actually doing in the first place. Some things are fine to use in the constructor/destructor, and some things should be in the OnStart/OnStop events instead. You need to provide more specific details if you want a more elaborate answer. Gambit
Technical Details
Message-ID:
<41ecbd8b$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<41ec832f@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,5b91f6aac9d5e006 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <41ec832f@newsgroups.borland.com> Subject: Re: Service termination Date: Mon, 17 Jan 2005 23:43:10 -0800 Lines: 37 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <41ecbd8b$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1106034059 68.69.17.41 (17 Jan 2005 23:40:59 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail