When I was in university back in 1990s, we were taught nothing about messages--only the threads (UNIX style). I think that's what confuses most people with async...
I suggest you to add a simple Sleep(1) to the message pump or perhaps use GetMessage instead of PeekMessage. This way both async and sync would not use 100% CPU. 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