[Lazarus] PostMessage return value
xrfang at gmail.com
Thu Sep 18 13:06:24 CEST 2014
2014-09-18 17:55 GMT+08:00 Michael Schnell <mschnell at lumino.de>:
> Sven made me know that by "event" you did not mean an object pascal
> language "Event" (i.e. a callback), but a "TEvent instance".
Sorry, I mean *neither*. I mean an RTLEvent. See this page:
What I need help to understand is, repeating my previous email:
While using ACriticalSection.Acquire, two threads are COMPETING for a
"token" to do certain task, hence you do not know WHICH thread eventually
get that token, although statistically each thread have the same chance of
getting the token in the long run.
While calling RTLeventWaitFor(), the calling thread gives up
chance to run, blocked until another thread calls RTLeventSetEvent() to
If the above understanding is correct, then I believe only RTLEvent can
"synchronize" threads, i.e., let them run in a *determined* order. While
CriticalSection ONLY provide a way to protect a shared resource is not
Alternatively, I have another "design":
while not Terminated do begin
if FCondition = true then begin
//do the job...
In the code above, I do not use event or critical section is it enough to
let this thread wait there, without wasting cpu time, until FCondition is
set (externally by the main thread)?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Lazarus