[fpc-pascal] Main thread wait and CheckSynchronize

Roland Schaefer roland.schaefer at fu-berlin.de
Fri May 14 00:18:18 CEST 2010


I have a seemingly simple question which nevertheless is giving me
headaches: I have a main thread which does nothing but [1] execute
CheckSynchronize, then [2] check whether some other things have to be
done as a result of the synchronization (and do those things if
necessary), then go back to [1] (until some quit condition is met).

Now, instead of busy waiting in the main thread loop (even with a Sleep
inserted), I'd rather have it idle wait until another thread needs to
synchronize. Is that possible?

I have tested a solution which achieves what I want (main thread waits
until some other thread wakes it) with a TEventObject, but that requires
threads to explicitly post a specific event and breaks support for
threads which simply expect CheckSynchronize to be called regularly.

I'd really appreciate any hints on this.


More information about the fpc-pascal mailing list