What I am trying to do is to create a field that is exclusive for each thread (created when a request arrives). I know that the server creates a thread when a request arrives, I’ve and don’t know how can I reference this dataModule from outside.
What I did was: create a threadvar variable in the unit, intercept the create and destroy events of the datamodule to fill and destroy it and let others units reference this variable.
Can I ask why you need to access dmCurrencyDecimals outside of TServicoMestre instance?
Probably better to have global instance like server data module, because your TdmCurrencyDecimals isn’t dependent on your service.
Hi,
The values inside dmCurrencyDecimals changes based on user’s request. We have lots of functions that fills this datamodule first, then do its thing and go. So we have to have this datamodule for each thread isolated in order to prevent one thread’s value modify others.
as for me, better to pass service instance (TServicoMestre) or dmCurrencyDecimals instance as a parameter to your threads so they can modify required variable.
as for me, better to pass service instance (TServicoMestre ) or dmCurrencyDecimals instance as a parameter to your threads so they can modify required variable.
Yes, this would be the right solution, unfortunately, we don’t have time to change all the code involved.