[fpc-pascal] TThread.Synchronize doesn't work in DLL
michael.vancanneyt at wisa.be
michael.vancanneyt at wisa.be
Tue Feb 1 14:08:16 CET 2011
On Tue, 1 Feb 2011, dibo20 at wp.pl wrote:
> Hi,
>
> I have form and thread in DLL. It seems that Synchronize() doesn't work.
> Thread is hanging on first Synchronize().
> It works only when I open form in ShowModal. I debug this and only difference
> between Show() is that ShowModal call WidgetSet.AppProcessMessages in loop. I
> can rewrite my code to use critical sections but what if this doesn't work
> too and I will waste my time?
You must call CheckSynchronize at regular intervals in the main thread.
WidgetSet.AppProcessMessages does this for you, that is why it works during
ShowModal()
Note that it is not enough to do this in the main application binary; That
will check for synchronisation with threads created in the main application.
To synchronize threads created in the DLL you must explicitly export a call
from your DLL which calls CheckSynchronize, and this call must be called
from the main program at regular intervals.
Michael.
More information about the fpc-pascal
mailing list