> No, I create the instance in the thread constructor. Any constructor for TThread class is executed in the context of the creating [likely main] thread, not the [future] created thread ! The new thread context exists only at the very beginning of the Execute method. So you must create any event-driven message based component from the Execute method or their events will run in the creating [main] thread and cause lot's of trouble when you access the component from the context of the created thread.
The execution context [thread context] has nothing to do with the fact that the executed code is part or not of the TThread class. It is only related if TThread.Execute is in the call stack. This is a frequent error for newbies in multithreading. > Must I create instance in Execute method Yes, you have. > or deplace listening method in constructor ? You must too, or in any function/procedure called directly or indirectly from the Execute method. That is you have the Execute method in the call stack. If you are unsure about the thread context a given function is run, you may call GetCurrentThreadID and compare with the value f the same function called at the very beginning of the Execute method. 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 -- 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