I recently started using the TPL Dataflow library from .NET 4.5 and the whole concept of blocks is new to me. I'm implementing a producer-consumer queue in my application, and I need to protect against duplicate messages being put in the queue, and therefore the need to check if a message has already been queued. I am using a BufferBlock<Message>
type (Message
is a custom type). BufferBlock
has the Count property but that doesn't help in this issue because the messages need to be uniquely identified.
Is there any way to check if a BufferBlock
contains an item or go through all the items and inspect them? Is it possible to cast BufferBlock
to something that allows iteration over the items? I'm following an example I saw on MSDN and it doesn't check if the item is in the queue, but I would think that checking the contents of a queue is a fairly needed operation. Any help is appreciated.