I need to have some kind of object that acts like a BroadcastBlock, but with guaranteed delivery. So i used an answer from this question. But i don\'t really clearly underst
Assuming you want to handle one item at a time by the broadcaster
while enabling the target blocks to receive that item concurrently you need to change the broadcaster
to offer the number to all blocks at the same time and then asynchronously wait for all of them together to accept it before moving on to the next number:
var broadcaster = new ActionBlock(async num =>
{
var tasks = new List();
foreach (var block in blocks)
{
tasks.Add(block.SendAsync(num));
}
await Task.WhenAll(tasks);
}, execopt);
Now, in this case where you don't have work after the await you can slightly optimize while still returning an awaitable task:
ActionBlock broadcaster = new ActionBlock(
num => Task.WhenAll(blocks.Select(block => block.SendAsync(num))), execopt);