Francois PIETTE wrote:
>> So in execute is it Ok to:
>>
>> while not terminated do
>> begin
>> WSocket.MessagePump;
>> // check if I need to do something
>> sleep(100);
>> end;
>> // close it all down
>> Or am I missing the point in the use of the message pump?
>>
>
> Yes, you miss something. The code you've done will be very slow at
> processing events because of the sleep. And it you remove the sleep, it will
> use all CPU.
You can use this to overcome "sleep" :
// If there are messages in the queue, then do not wait at all,
else, wait
// as little as possible, so as to avoid 100% CPU usage and still
process
// as fast as we possibly can.
MsgWaitForMultipleObjectsEx(0, pHandles, 1, QS_ALLINPUT,
MWMO_ALERTABLE);
Obviously, one has to understand message processing in the first place...
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be