[fpc-pascal] Main thread wait and CheckSynchronize
Michael Van Canneyt
michael at freepascal.org
Mon May 17 09:30:09 CEST 2010
I think that what you did is the only right solution. Synchronizing
threads is tricky, and the default mechanism is meant for GUI apps
where the main thread is the GUI thread.
On Sun, 16 May 2010, Roland Schaefer wrote:
> Allow me to bump this. I'd appreciate any comments, even if it's "Why on
> earth do you want to do that!?" or something.
> On 14.05.2010 00:18, Roland Schaefer wrote:
>> I have a seemingly simple question which nevertheless is giving me
>> headaches: I have a main thread which does nothing but  execute
>> CheckSynchronize, then  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  (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.
>> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
More information about the fpc-pascal