Francois Piette wrote:
>> In triggersessionclosed, I postthreadmessage to a message handler in
>> the same worker thread which then thread-detaches and posts the
>> object to listener thread. However, in every 1-2 hours, under heavy
>> load, the worker thread gives an AV which I suspect is due to a
>> recv/send callback event being launched after threaddetach. How can
>> I prevent this? 
> 
> If you had looked at the source code, you could have seen that when
> ThreadDetach is called, the socket is asked to stop sending
> notifications (WSAASyncSelect is called with nul mask) and the hidden
> window is cancelled. So technically speaking, no notification can
> take place before you attach the socket again to a thread in which
> case a new hidden window is assigned and WSAASyncSelect called to
> request notifications from winsock. 
> 
> In ICS-V6, the hidden window is shared by several components.
> ThreadDetach unregister the messages which where used by the
> component. 

Even if there were still such unregistered messages pending in the message
queue due to the hidden window still exists (handling messages for other
components of that thread) those unregistered messages won't be touched
by the component but handled by DefWindowProc, so no problem. If the
hidden window has been destroyed Windows flushes the thread message
queue so GetMessage() should never see a message for a non-existing
window.

--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
-- 
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