Take a look at BroadcastBlock<T>
, which only holds the most recent item posted to it. You can put a broadcast block in front of an ActionBlock<T>
.
While posting a new item to the broadcast block won't cancel the item currently being processed by the action block, it will overwrite any existing item already held by the broadcast block; in effect discarding any older messages not yet processed by the action block. When the action block completes its current item, it will take the most recent item posted to the broadcast block.