[fpc-pascal] Main thread wait and CheckSynchronize

Michael Van Canneyt michael at freepascal.org
Mon May 17 09:30:09 CEST 2010


Hello,

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.

Michael.

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.
>
> Thanks
> Roland
>
> On 14.05.2010 00:18, Roland Schaefer wrote:
>> Hello,
>>
>> 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.
>>
>> Cheers
>> Roland
>> _______________________________________________
>> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



More information about the fpc-pascal mailing list