06-04-2019, 03:48 AM
(This post was last modified: 06-04-2019, 03:50 AM by Alexandre Machado.)
A quick and dirty way to implement it would be:
- Create a unit where you have a shared (global) variable which holds a TCriticalSection (let's name it HandlersCS).
- Create a TCriticalSection in unit initialization. Destroy it in unit finalization.
- In your TContentHandler.Execute() method do this:
HandlersCS.Enter;
try
// Do your thing here
finally
HandlersCS.Leave;
end;
All your current logic should be between Enter..Leave above.
This will effectively serialize all calls using that content handler class
- Create a unit where you have a shared (global) variable which holds a TCriticalSection (let's name it HandlersCS).
- Create a TCriticalSection in unit initialization. Destroy it in unit finalization.
- In your TContentHandler.Execute() method do this:
HandlersCS.Enter;
try
// Do your thing here
finally
HandlersCS.Leave;
end;
All your current logic should be between Enter..Leave above.
This will effectively serialize all calls using that content handler class