Fastream Technologies wrote:
> 
> I suggest you to add a simple Sleep(1) to the message pump 

This would result in very poor performance, it's really not
recommended, even though it works ;-)

For a simple message loop have a look at CtrlSocket.MessageLoop,
it is the built-in message pump that you can call. Property
CtrlSocket represents the underlying TWSocket instance,

If you want to write your own one take a look at the BDE
service framework: SvcMgr.pas TServiceThread.ProcessRequests(),
as an example of a thread message pump.  

---
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html

> Regards,
> 
> SubZ
> 
> ----- Original Message -----
> From: "Francois Piette" <[EMAIL PROTECTED]>
> To: "ICS support mailing" <twsocket@elists.org>
> Sent: Wednesday, May 17, 2006 4:27 PM
> Subject: Re: [twsocket] thread message loop question
> 
> 
>> You have high CPU usage because you use sync methods. Use Async and
>> you'll have the best CPU usage.
>> You probably don't need multithreading at all. The component will
>> download your files in the bacground without using any thread.
>> 
>> To have the component work in a thread, you _must_ create it dynamically
>> from the thread's execute method. If you don't, the component event will
>> be handled by the main thread and your worker thread will almost do
>> nothing :-) 
>> 
>> I don't understand what you don't understand about message loops within
>> threads.
>> 
>> --
>> Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
>> --
>> [EMAIL PROTECTED]
>> Author of ICS (Internet Component Suite, freeware)
>> Author of MidWare (Multi-tier framework, freeware)
>> http://www.overbyte.be
>> 
>> 
>> ----- Original Message -----
>> From: "Carsten Muencheberg" <[EMAIL PROTECTED]>
>> To: <twsocket@elists.org>
>> Sent: Wednesday, May 17, 2006 2:33 PM
>> Subject: [twsocket] thread message loop question
>> 
>> 
>>> Hi,
>>> 
>>> I am using THttpClient from inside a TThread object for downloading
>>> several files sequentially. At present the implementation is
>>> synchronous, setting MultiThreaded = true then calling Get().
>>> 
>>> I noticed a high CPU load while downloading, but I am not sure whether
>>> this comes from the download processing or from an error in my thread
>>> implementation. I might change the whole thing to asynchronous
>>> (GetASync()), but I have a question concerning my current
>>> implementation. In WSocket.pas I found the following comment:
>>> 
>>> "For both methods to work, you MUST have a message loop withing your
>>> thread. Delphi create a message loop automatically for the main thread
>>> (it's in the Forms unit), but does NOT create one in a thread ! For your
>>> convenience, TWSocket has his own MessageLoop procedure. You can use it
>>> from your thread."
>>> 
>>> What is meant by "using the MessageLoop procedure"? You I have to code
>>> or assign something to make it work correctly? I checked the sample
>>> programs, but did not find anything in that regard.
>>> 
>>> Carsten
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>> 
>> 
>> -------------------------------------------------------------------------
>> --- ----
>> 
>> 
>>> --
>>> To unsubscribe or change your settings for TWSocket mailing list
>>> please goto http://www.elists.org/mailman/listinfo/twsocket
>>> Visit our website at http://www.overbyte.be
>> 
>> --
>> To unsubscribe or change your settings for TWSocket mailing list
>> please goto http://www.elists.org/mailman/listinfo/twsocket
>> Visit our website at http://www.overbyte.be
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to