Patrick Wong wrote:
> Dear all,
> 
> In my application I am using a TWSocket in a working thread for heavy
> traffic to/from server.  Since there is no window in thread the
> TWSocket requires the MessageLoop() to receive events.  My approach
> is when there is no data to send the TWSocket keeps to be looped
> within the MessageLoop(), processes received data in
> FClientDataAvailable.  When there are data to be sent, the main
> thread PostMessage(m_FClientSocket->Handle, WM_QUIT, 0, 0) to let it
> to call send method. 
> 
> The problem is when the incoming data are received continually, the
> thread is not able to receive WM_QUIT from message queue at all,
> causing all outgoing data to be blocked.  

WM_QUIT message kills the message loop and sets property TWSocket's
property Terminated to True. Instead you should write your own message
loop and use custom messages to communicate with the worker thread.

> I tried Sleep(10) in FClientDataAvailable

Don't do that, Sleep() does nothing else but sleep that means nothing,
including not processing messages.

> and sometimes the MessageLoop can be broken, but
> not always.    

Include wsoNoReceiveLoop in the ComponentOptions to make the
component more responsive when it receives data. If wsoNoReceiveLoop
is not set TCustomWSocket.AsyncReceive receives data in a loop _without
processing messages as long as data is available to be read.  

-- 
Arno Garrels
--
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

Reply via email to