I have the following code:
If Not Application("ServicesQueueActiveDict").Exists( nID ) Then 'we are good to process, this item is not Active....add it now Application("ServicesQueueActiveDict").Add nID, Now Else 'do whatever
The “ServicesQueueActiveDict is a caprock.dictionary.
I get the error referenced in this subject, “This key is already associated with an element of this collection.” when the If branch executes. The problem is, if the nID exists, why is the code then trying to add it again? Shouldn’t it then execute the Else branch?
nID is a simple integer, by the way.
Is there any risk here of threading issues? Your code doesn’t show any locking so could another thread be coming through between the execution of the .Exists test and the addition attempt?