[Lazarus] PostMessage return value
Michael Schnell
mschnell at lumino.de
Thu Sep 18 14:18:58 CEST 2014
On 09/18/2014 01:46 PM, Xiangrong Fang wrote:
> 2014-09-18 19:34 GMT+08:00 Michael Schnell <mschnell at lumino.de
> <mailto:mschnell at lumino.de>>:
>
>
> I think, in the other mail, I did explain how "Wait" is supposed
> to work in TThreadPool.
>
>
> Initially, when the threadpool is created, Wait is hold by the main
> thread, so the worker just wait there, no problem, but after the
> worker thread get the CS, it started working, then RELEASE the CS.
>
> This is when the problem arise: after worker release the CS, how do
> you ensure it is the MAIN thread who will get the CS next, NOT the
> worker thread again?
>
The Thread uses "synchronize(NotifyStopped)" to call a procedure that is
run in the main thread (and it waits until this procedure is done). In
this synchronized procedure, the main thread Acquires "wait" again, and
hence the worker thread will block at the start of the next main loop turn.
-Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20140918/3d483e7e/attachment-0003.html>
More information about the Lazarus
mailing list