🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: starting with threads

#12140
From: Harri
Date: Sun, 24 Nov 2002 19:51
57 lines
2263 bytes
Hi Martin,

> currentLiveQueryThreads:TThreadList;

in case someone else is looking for this, that's
what I did:

> Add new ThreadQuery instances to the list in the constructor.
...
 with CurrentLiveQueryThreads.LockList do
  begin
    try
     Add(Self);
    finally
      CurrentLiveQueryThreads.UnlockList;
    end;
  end;
...
> remove the threads from the list before exiting the thread.
...
  with CurrentLiveQueryThreads.LockList do
  begin
    try
      for i := Count - 1 dowto 0 do
        if Items[i] = Self then
          Remove(Items[i]);
  {  // -- or longer version --
      for i := 0 to Count - 1 do begin
        if Items[i] = Self then
        begin
          Remove(Items[i]);
          break;
        end;
      end;
   }
    finally
      CurrentLiveQueryThreads.UnlockList;
    end;
  end;
  inherited Destroy;
...

> If you want to terminate all the threads, lock the list & iterate it,
> call the terminate method for each thread & unlock the list.

  with CurrentLiveQueryThreads.LockList do
  begin
    try
      for i := 0 to Count - 1 do
        ThreadQuery(Items[i]).Terminate;
    finally
      CurrentLiveQueryThreads.UnlockList;
    end;
  end;

thanks,
Harri
Technical Details
Message-ID: <3de12d8b@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mail
References: <3de0c520$1@newsgroups.borland.com> <3de0d40b@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f94dd,b96fe3fe7bf7dbad
X-Google-Attributes: gidf94dd,public
X-Google-ArrivalTime: 2002-11-24 12:15:20 PST
Reply-To: "Harri" <harri@uninet.ee>
From: "Harri" <harri@uninet.ee>
Newsgroups: borland.public.delphi.nativeapi
References: <3de0c520$1@newsgroups.borland.com> <3de0d40b@newsgroups.borland.com>
Subject: Re: starting with threads
Date: Sun, 24 Nov 2002 21:51:24 +0200
Lines: 59
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: <3de12d8b@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1038167435 62.65.223.42 (24 Nov 2002 11:50:35 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mail