Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Oct : Re: Multi-Threading

www.cryer.info
Managed Newsgroup Archive

Re: Multi-Threading

Subject:Re: Multi-Threading
Posted by:"Martin James" (nospam@dial.pipex.com)
Date:Mon, 16 Oct 2006 17:40:37

Err... OK.


First, how often does your app download a web page?  If it performs
downloads often, there is little point in continually
creating/terminating/freeing threads and other complex components, (like
TidHTTP), to do the downloads - it's much easier and safer to keep the
threads and components around.

Then there's this:

           Start;
       finally
          downloadThread.Free;

I'm not sure what 'start' does either but, unless it is a synchronous
signaling mechanism, (which I'm pretty sure it is not),  there is a real
chance that the download thread will not run at all because you are
freeing it in the very next line.  Even if the OS does run the download
thread immediately, (either on another processor or by preempting the
main thread), the first time the download thread blocks, (as it will on
the TidHTTP socket calls), the main thread will run again and the
download thread will be freed.  What happens in TidThread.destroy I do
not know, but I'm pretty sure that you do not want to call it before the
download thread has actually done some downloading.


Remy Lebeau, (Indy expert), may well find other issues/problems <g>


Rgds,
Martin

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive