🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.nativeapi
Article #12127

starting with threads

#12127
From: Harri
Date: Sun, 24 Nov 2002 12:25
48 lines
2339 bytes
Hi!

I modified ibx threaded query example (from codecentral)
a little, but it is still not what I would like.

ThreadQuery = class(TThread)
  private
    dmThread: TdmThread; // dynamically created datamodule
 ...
end;

var
  thdQuery : ThreadQuery;

and in other unit :
..
thdQuery := ThreadQuery.Create(..
..

Thread is set "FreeOnTerminate := True" in constructor
and has "dmThread.Free" inside destructor as in example.
I'm not creating any other components dynamically.

Now, if close main form, when thread is running, I get lots
of AV-s. I managed to create "running threads count"
variable, what forbids program exit, if threads count is >0.
but this is really a temporary solution. In delphi threads
example one can close main form when sort threads are running.

I'm too stupid in this area to create thread pool so I thought
it would be possible to do something like:

var
  thdQuery1, thdQuery2, thdQuery3 : ThreadQuery;

and just use one of these three variables (whichone is not
currently used). This leads to the following questions:
if I start query like:
thdQuery2 := ThreadQuery.Create(..

1) how can I set thdQuery2 to nil from thread, when it exits
2) is it legal to set  thdQuery2.Terminated := True; even if
thread is set to autoterminate
3) what should happen, when I close main form - are threads
terminated automatically or they continue run to end.

best regards,
Harri
Technical Details
Message-ID: <3de0c520$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!newsfeed1.cidera.com!Cidera!news.uni-x.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f94dd,b96fe3fe7bf7dbad,start
X-Google-Attributes: gidf94dd,public
X-Google-ArrivalTime: 2002-11-24 05:19:03 PST
Reply-To: "Harri" <harri@uninet.ee>
From: "Harri" <harri@uninet.ee>
Newsgroups: borland.public.delphi.nativeapi
Subject: starting with threads
Date: Sun, 24 Nov 2002 14:25:54 +0200
Lines: 58
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 62.65.223.42
Message-ID: <3de0c520$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1038140704 62.65.223.42 (24 Nov 2002 04:25:04 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!newsfeed1.cidera.com!Cidera!news.uni-x.net!newsgroups.borland.com!not-for-mail