I have a concurrent dictionary which I am using it to do some thread-safe functionalities.
For example I have the following code :
var myConcurrenctDictionary= new ConcurrentDictionary<int,int>();
if (myConcurrenctDictionary.TryAdd(personId, personId) == false)
{
throw new Exception("");
}
But now I need a thread-safe way to try adding multiple values to the concurrent dictionary at once, which returns false and not inserting any values of the specified ids if it fails.
So, could you please guide me to how I can implement that?