[fpc-pascal] TThread.WaitFor not returning?

Henry Vermaak henry.vermaak at gmail.com
Wed Sep 17 11:50:40 CEST 2008


On 17/09/2008, Graeme Geldenhuys <graemeg.lists at gmail.com> wrote:
> On 9/17/08, papelhigienico at gmail.com <papelhigienico at gmail.com> wrote:
>> When you call synchronize from inside of you thread, this sends a message
>> to
>> application thread with the procedure that will be used to synchronize AND
>> WAIT FOR a response from application thread of the execution of sync
>> procedure. BUT when you call Thread.WaitFor in application thread, the
>> application don't process any messages because it is waiting the thread
>> finish, and thread don't finish because it is waiting a response of
>> application thread of the execution of sync procedure... and you have your
>> aplication freeze!
>
> This is exactly what seems to be happening... I'll try your
> work-around and see how it goes. Thanks.
>
> Note:
> I have no such issues in Delphi, using the exact same threading code.
> So does that mean FPC has a bug in threading?

Delphi has code in its WaitFor function that prevents this deadlock
from occuring.  They basically wait on the SyncEvent and the handle of
the thread, calling CheckSynchonize when the SyncEvent triggers.

I'm not sure if this is possible with fpc, but I'm sure there must be
a solution.

henry



More information about the fpc-pascal mailing list