Article View: borland.public.cppbuilder.nativeapi
Article #13503Re: Problem with Stringlist in service application
From: Victor G. Baron
Date: Sat, 11 Oct 2003 06:59
Date: Sat, 11 Oct 2003 06:59
65 lines
3569 bytes
3569 bytes
>>:| >>:|> __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. The bulk of this code was copied from the Using Threads example in the Helpfile for TServiceApplication. I can't answer for why they set it up that way. >>:| >>:|> 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? The loop should execute every 10 minutes - it will read and parse and write out a file on a server. The file being processed is a user list that is updated everytime a user logs on so , yes, i want to process it every 10 minutes. >>:| >>:|> // 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. The delete is outside the while loop. >>:| >>:|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). >>:| >>:|That call will re-iterate the loop every 6 seconds, not every 10 minutes. >>:|10 minutes would be (1000*60*10), or 600,000. LOL - yes, for testing I didn't want to wait 10 minutes. I've moved stuff around trying different things but this is back to the original way. I've stripped out everything except the code that crashes. Thanx for the help - Vic -- Vic Baron I haven't lost my mind, it's backed up on disk somewhere!
Technical Details
Message-ID:
<18afov85hscnd8n1qjjh41bqgceis3cb0i@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<ppueovg2k6grk500sgq49urri491tltrk7@4ax.com> <3f87807f$1@newsgroups.borland.com> <rn2fovgubqp92b3gv6te6rhj7kh0ih4p30@4ax.com> <3f8791ec@newsgroups.borland.com> <525fovoj0ltdsbhpo7vo2tsen3nrsa2g1l@4ax.com> <3f87a6b6$1@newsgroups.borland.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-11 00:09:00 PST From: Victor G. Baron <vgbaron@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Problem with Stringlist in service application Date: Fri, 10 Oct 2003 23:59:29 -0700 Message-ID: <18afov85hscnd8n1qjjh41bqgceis3cb0i@4ax.com> References: <ppueovg2k6grk500sgq49urri491tltrk7@4ax.com> <3f87807f$1@newsgroups.borland.com> <rn2fovgubqp92b3gv6te6rhj7kh0ih4p30@4ax.com> <3f8791ec@newsgroups.borland.com> <525fovoj0ltdsbhpo7vo2tsen3nrsa2g1l@4ax.com> <3f87a6b6$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 66.120.230.18 X-Trace: newsgroups.borland.com 1065855559 66.120.230.18 (10 Oct 2003 23:59:19 -0700) Lines: 65 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail