Recent

Author Topic: Using Synchronize in a DLL  (Read 6216 times)

calvarez

  • Newbie
  • Posts: 3
Using Synchronize in a DLL
« on: April 01, 2010, 04:55:31 pm »
I written an application that loads a DLL. The application also takes care of calling an exported function from the DLL to create and start a thread in the DLL. When the thread is running, it will be listening to packets that arrives at the servicing port. I encountered a problem if I wrapped my calls within the Execute(...) function with Synchronize(...). The application in fact, hang at the first wrapped Synchronize(...) call. However, if I take the wrapper out, the
application seems to be running fine. Previously, before I split my application into a DLL and a caller application, the use of Synchronize(...) posed no problems. But when I use
Synchronize(...) in a DLL, there are problems mentioned above. Thanks and kind regards.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7846
Re: Using Synchronize in a DLL
« Reply #1 on: April 12, 2014, 11:21:09 am »
The trouble is that you have two sets of state related to synchronizing, since both the mainprogram and the DLL have a complete copy of the RTL state. (all variables)

To transparently divide a program in to multiple modules (mainprogram and DLLs) you need packages.

A workaround would be to somehow call the tthread.synchronize in the main program (e.g. by callback or so) so that all synchronization is done with only the mainprogram state.
« Last Edit: April 12, 2014, 06:59:54 pm by marcov »

eny

  • Hero Member
  • *****
  • Posts: 1588
Re: Using Synchronize in a DLL
« Reply #2 on: April 12, 2014, 12:27:47 pm »
To transparently divide a program in to multiple modules (mainprogram and DLLs) you need packages.
You mean this url  :)
All posts based on: Win10 (Win64); Lazarus 1.8.0 'stable' (#56594 win64) unless specified otherwise...