On Sun, 2009-01-11 at 01:17 +0100, Hans-Peter Diettrich wrote: > David W Noon schrieb: > > > This looks rather like some sort of deadlock on something like a mutex > > semaphore -- but that's just a guess. Is there some "knack" to calling > > Dispatch() that avoids this problem? > > The solution is simple: don't use Dispatch() from a thread, use the > thread-safe SendMessage instead.
The only function like that I could find was SimpleSendMessage(), which produced the same result as Dispatch() and DeliverMessage(), but without supplying any message data. In which unit is SendMessage() defined? I finally resolved the issue by changing the pointer to the form into an object reference to a TObject. After that, Dispatch() worked as documented (such as it is documented). Moreover, the action I needed was a "post", not a "send". It is the "send" style of message transfer that causes deadlocks between the worker thread and the user interface thread. This is because "send" waits for a return code from the message handler, whereas "post" just places the message on the queue and proceeds regardless. -- Regards, Dave [RLU #314465] ======================================================================= [email protected] (David W Noon) ======================================================================= _______________________________________________ Lazarus mailing list [email protected] http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
