🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Problem with Stringlist in service application

#13501
From: Remy Lebeau (TeamB)
Date: Sat, 11 Oct 2003 06:46
45 lines
2959 bytes
"Victor G. Baron" <vgbaron@hotmail.com> wrote in message
news:525fovoj0ltdsbhpo7vo2tsen3nrsa2g1l@4ax.com...

> In the header I have this:

I didn't need the service code, just the thread code related to the
TStringList and its usage.

> __fastcall TConvThread::TConvThread(bool CreateSuspended)

What are you setting CreateSuspended to?  Under BCB5, if you set
CreateSuspended to false, the underlying thread object can begin running
before the constructor has had a chance to execute to initialize the
thread's members.  If you are not already doing so, you should always create
a thread suspended and then manually Resume() it after the constructor is
finished doing what it needs to do.

>    while (!Terminated)

How many times are you actually processing the file?  If once, then you need
to get rid of the while() loop altogether, otherwise you will process the
same file over and over and over.  Is that what you really want?

>    // and clean up the string list
>    delete inputfile;

Are you freeing the TStringList *inside* the while() loop?  If so, then the
code will crash on the second iteration of the list as the pointer will
still contain a memory address (since you did not set the pointer to NULL
after the deletion) but the actual memory being pointed to will no longer be
valid.  That's probably your actual crash right there.

To ensure that the TStringList is always valid for each iteration of the
loop, you need to free it outside the loop, not inside of it.  Better would
be to move the instantiation back into the thread's constructor rather than
inside Execute() (and of course adding a destructor to free it).

>     Sleep(6000);   // cycle every ten minutes

That call will re-iterate the loop every 6 seconds, not every 10 minutes.
10 minutes would be (1000*60*10), or 600,000.


Gambit
Technical Details
Message-ID: <3f87a6b6$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <ppueovg2k6grk500sgq49urri491tltrk7@4ax.com> <3f87807f$1@newsgroups.borland.com> <rn2fovgubqp92b3gv6te6rhj7kh0ih4p30@4ax.com> <3f8791ec@newsgroups.borland.com> <525fovoj0ltdsbhpo7vo2tsen3nrsa2g1l@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,4f6a692a96789751
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-10-10 23:55:20 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <ppueovg2k6grk500sgq49urri491tltrk7@4ax.com> <3f87807f$1@newsgroups.borland.com> <rn2fovgubqp92b3gv6te6rhj7kh0ih4p30@4ax.com> <3f8791ec@newsgroups.borland.com> <525fovoj0ltdsbhpo7vo2tsen3nrsa2g1l@4ax.com>
Subject: Re: Problem with Stringlist in service application
Date: Fri, 10 Oct 2003 23:46:05 -0700
Lines: 47
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.137.75
Message-ID: <3f87a6b6$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1065854646 67.22.137.75 (10 Oct 2003 23:44:06 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail