Removing a specific item from BlockingCollection <>

Is there a way to remove a specific element from a BlockingCollection, for example:

IMyItem mySpecificItem = controller.getTopRequestedItem();
bool took = myBlockingCollection<IMyItem>.TryTake(out mySpecificItem);
if(took)
  process(mySpecificItem);
.....

In other words: I want to remove an element from BlockingCollection <>, which is identified by some field (for example, ID), and not just the next available element.

Do I need to implement getHashCode () or IComparer?

+5
source share
1 answer

BlockingCollection<>will not help you. I think you need to ConcurrentDictionary<>.

+7
source

All Articles