put a flag before you add, if flag is true do not add another, false the flag when added, then the next can give it a try.
This doesn't work, it's not "thread safe" (the task can be interrupted between checking and setting the flag).
I see the reason behind this, and also the reason to build a thread safe dictionary object. And believe me I'm thinking in an OOP way... sometimes a bit too object-oriented for CoDeSys
Many of us have C or C++ coding practice, and it's nice to see similar features in CoDeSys, but IEC-61131-3 requires slightly different approach than regular application programming...
About the practice of not writing the same variables from different places: this is true for IEC variables, mostly "%Q". But here, we are talking about a function block, that can be called from multiple tasks, multiple locations.
Back to the question, in CoDeSys V3 you have:
These calls are blocking, so be careful with them.
Between these two calls the above mentioned "flag" could be checked and set. Just make sure, that this flag is not used anywhere else... (should be a global, (or static), used only by this FB/Object). For "standard" non-blocking resource management use CAA.SEMA, or CAA.BOLT.
As for the "thread safety" of these "library calls": they are intended to be used for synchronization purposes, I don't know how the CoDeSys compiler does that, but hopefully it does correctly.