🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #9400

Re: indicating a service fails to start

#9400
From: Benjamin Pratt
Date: Fri, 09 Jul 2004 19:45
46 lines
1985 bytes
Remy, thanks for responding.

I am not using the Execute handler. Here is the code widdled down to the
smallest reproducable example:

void __fastcall TDynaPowerDX::ServiceStart(TService *Sender, bool &Started)
{
   try
   {
      DataExchange = new TDataExchangeThread(false);
      Started = true;
   }
   catch(...)
   {
      MessageBox(HWND_DESKTOP, "Exception caught!", "Exception",
            MB_OK | MB_SERVICE_NOTIFICATION);
      Started = false;
   }
}

void __fastcall TDynaPowerDX::ServiceStop(TService *Sender, bool &Stopped)
{
   DataExchange->Terminate();
   DataExchange = NULL;
   Stopped = true;
}

__fastcall TDataExchangeThread::TDataExchangeThread(bool CreateSuspended)
   : TThread(CreateSuspended)
{
    throw 0;
}

void __fastcall TDataExchangeThread::Execute()
{

   while(!Terminated)
   {
      Sleep(0);
   }
}


For some reason, when the thread constructor throws, the catch block in
ServiceStart does not catch the exception. I have put a MessageBox in the
catch to test it, and it never is displayed.
Technical Details
Message-ID: <40eef575@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40eedd30$1@newsgroups.borland.com> <40eeee9b@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,6b63c33df8d56275
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Benjamin Pratt" <benjamin.pratt.getridofthis@verizon.net>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40eedd30$1@newsgroups.borland.com> <40eeee9b@newsgroups.borland.com>
Subject: Re: indicating a service fails to start
Date: Fri, 9 Jul 2004 12:45:27 -0700
Lines: 48
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: 66.245.208.182
Message-ID: <40eef575@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1089402229 66.245.208.182 (9 Jul 2004 12:43:49 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail