Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-02

TThread.Synchronize doesn't work in DLL

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

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?

Regards

Marco van de Voort
to Unknown author

In our previous episode, said:

I have form and thread in DLL. It seems that Synchronize() doesn't work. Thread is hanging on first Synchronize().

Probably you have two RTLs, one in the RTL and one in the main program. As far as I know this will also fail in Delphi.

Unknown author
to Unknown author: I have form and thread in DLL. It seems that Synchronize() doesn't work. Thread is…
Show quoted text 8 lines
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.

Unknown author
to Unknown author

W dniu 01.02.2011 14:08, pisze:

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.

Hm so I have problem because I don't have source of main application and my DLL is only plugin :) .
Exists another way? Does DLL have a some main loop in which I can callCheckSynchronize or can I create own loop without blocking user interface?
I need this for lNet HTTP client. Eventer in this component doesn't work in DLL so I am looking for the best way for calling TLHTTPClient.CallAction manually in some loop.