How to achieve remove_if functionality in .NET ConcurrentDictionary

.NET doesn’t expose a RemoveIf directly, but it does expose the building blocks necessary to make it work without doing your own locking. ConcurrentDictionary implements ICollection<T>, which has a Remove that takes and tests for a full KeyValuePair instead of just a key. Despite being hidden, this Remove is still thread-safe and we’ll use it … Read more