On the producer side of my program, while processing the items which will be sent to the collection, they must be checked whether a duplicate one is in the queue, so I need to loop through the BlockingCollection<ConcurrentQueue<Message>>
at first place. But I could't find out how to loop through a blocking collection.
public BlockingCollection<ConcurrentQueue<Message>> Collection { get; set; }
= new BlockingCollection<ConcurrentQueue<Message>>();
foreach(var item in Collection)
{
//item is ConcurrentQueue<Message>
}
foreach (ConcurrentQueue<Message> queue in Collection)
{
foreach (var item in queue)
{
//I don't know if it is efficient but I can reach like that
}
}
foreach(var item in Collection.Queue)
{
// Is there an api something like that?
}