Article View: borland.public.cppbuilder.internet.socket
Article #2839Re: Problem with HTTP download locking up.
From: Remy Lebeau (TeamB)
Date: Tue, 24 Jan 2006 01:18
Date: Tue, 24 Jan 2006 01:18
58 lines
3498 bytes
3498 bytes
"Tom" <thomasf1021@hotmail.com> wrote in message news:43d571a6$1@newsgroups.borland.com... > The next file that gets downloaded is 24MB and as soon as the > Get is called the program freezes solid. Are you calling Get() in the context of the main thread? If so, then the freeze is to be expected. > I do have the AntiFreeze component on the form, and on my machine > that doesn't lock up it functions just fine with being able to move the > window, click buttons etc without it appearing to be frozen. TIdAntiFreeze is not perfect. A better solution would be to move the downloading into a separate worker thread instead. > On his, it's locked up solid, can't move the windows, click the cancel button, nothing. Then TIdHTTP (or something else in your code) has been completely blocked > to the point where TIdHTTP cannot even call into TIdAntiFreeze at all. Again, you should move the download into a separate thread. At least that way, the program will not be frozen even if such a blockage occurs again. > I have the OnWork event setup to calculate the current progress > of the transfer using the Http1->Response->ContentStream->Position > and the ContentLength variables. The ContentStream->Position is always at the end of the stream You should be using the AWorkCount value that is provided by the OnWork event instead. That is the total number of bytes that have been transferred since the beginning of the transfer. > With a Application->ProcessMessages() thrown in to update > the display. TIdAntiFreeze calls ProcessMessages() internally. Or, if you move the code into its own thread, then ProcessMessages() is not needed at all. > Initially I had it setup in a thread for the downloading with > synchronize calls for updating the display, but rather than lockup, > the thread was just dying without any errors being thrown. Then your thread code was likely wrong to begin with. Please show what you were doing. Also keep in mind that TThread swallows uncaught exceptions, so if you want an exception to be reported, you have to catch the exceptions yourself so that you can respond to them accordingly. > bool Download(AnsiString const FileName, AnsiString const FullPath) That code has a memory leak if either TIdHTTP::Get() or TMemoryStream::SaveToFile() fail. You are also doing a lot of processing inside the OnWork event handler. You might consider streamlining the code better to reduce the numbr of placesd where errors can occur. Gambit
Technical Details
Message-ID:
<43d57fba$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!newsfeed.wirehub.nl!194.72.7.126.MISMATCH!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<43d571a6$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,1a95ad1eb7ec8c80 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <43d571a6$1@newsgroups.borland.com> Subject: Re: Problem with HTTP download locking up. Date: Mon, 23 Jan 2006 17:18:13 -0800 Lines: 60 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <43d57fba$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1138065338 68.69.17.41 (23 Jan 2006 17:15:38 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!newsfeed.wirehub.nl!194.72.7.126.MISMATCH!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail