🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #76

TNMHTTP vs. TIdHTTP

#76
From: Carlos Moreno
Date: Mon, 21 Apr 2008 22:35
61 lines
3074 bytes

On a subject somewhat related to my previous post... 

I guess a preliminary question would have to be whether there is 
a package library that I could install with C++ Builder 2007 that 
would give me access to the "legacy" TNMHTTP control  (how can I 
find out what packages contain what, and whether or not something 
is available?)

Anyway, the issue I have right now is the following:  I replaced 
the TNMHTTP control with an Indy control TIdHTTP, for an 
auxiliary class that I have that retrieves an image from a 
web site and places it in a TImage control (providing local 
caching of images, etc.).

The HTTP control is in a class that inherits from Thread.  In 
the Execute method of this class, I do  (exception-handling and 
other housekeeping omitted):

    http = new TIdHTTP (Application);  // http is a data member
    TFileStream * file = new .... (localfile.c_str() ... );
        // localfile is also a data member, an std::string
    http->Get (url, file);
    delete file;
    Synchronize (SetImage);


Where my SetImage method looks like this:

    image->Picture->LoadFromFile (localfile.c_str());
        // image is a data member, a TImage * that was 
        // passed to the constructor, so that this object 
        // places the image in that control

With TNMHTTP, the above was working flawlessly;  it's on a 
separate thread, so it does not block the GUI.  In particular, 
if I have multiple downloads going on concurrently, I see them 
appear one by one.

However, with the Indy HTTP control, it would seem like it does 
block everything --- I can't even grab the main window and move 
it;  everything freezes until *all* downloads are completed and 
the images do show up  (all of them simultaneously).

How could this happen?   The HTTP control is running on a 
separate thread --- how come it blocks the entire GUI? (the 
constructor sets Priority to tpLower, by the way)

I also tried passing NULL to TIdHTTP's constructor  (really 
a shot in the dark).  The behaviour remains identical --- it 
works, but it freezes the GUI until all downloads are completed 
and all the images show up.

Any explanation for this?

Thanks!

Carlos
--
 
Technical Details
Message-ID: <480d16b3$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.isoc.lu!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,b9c5ec9c3a621e4,start
X-Google-Attributes: gid11508e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Carlos Moreno" <moreno_h3gd@mochima.com>
Sender: "Carlos Moreno" <moreno_h3gd@mochima.com>
Reply-To: "Carlos Moreno" <moreno_h3gd@mochima.com>
Subject: TNMHTTP vs. TIdHTTP
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 67.142.130.38     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <480d16b3$1@newsgroups.borland.com>
Date: 21 Apr 2008 15:35:31 -0700
X-Trace: newsgroups.borland.com 1208817331 207.105.83.66 (21 Apr 2008 15:35:31 -0700)
Lines: 61
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.isoc.lu!newsgroups.borland.com!not-for-mail