robertoschler wrote: > I have a TWSocket component with a background thread. I do use the > Thread.Attach method as I saw in the sample code to switch it to the > background thread I create, and I also set the socket's Multithreaded > property to true. I also double-checked with the Delphi thread > window to confirm it's doing work on a background thread. > > If I make a Send call to that socket, does it have to occur on the > same thread as the worker thread? Or can I call it's Send method > from another thread? I looked at the WSocket.pas code and I didn't > see anything that looked like it wasn't thread-safe, but I'm having > some strange problems like missing OnDataAvailable() events so I > wanted to check.
As rule of thumb, TWSocket objects should only be accessed from one thread context at the same time even though some parts, such as the send buffer are protected by a critical section. Access from multiple threads has to be synchronized. Once attached to your worker thread events will trigger *in worker thread context*, if you do not attach it to a different thread context events trigger in context of the creator thread. Note that method Send is async and returns immediately, data is actually buffered and sent delayed in the background. -- 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