I'm using ActionBlock
and I tested if it's working properly like below and sometime Actionblock
misses actions and it shouldn't happen at all
Why is this happening and how can i fix it?
var n = 0;
var action = new Action<int>((i) =>
{
n++;
//...job...
}
for (int i = 0; i < size; i++)
{
var block = new ActionBlock<int>(i => action(i),
new ExecutionDataflowBlockOptions { MaxDegreeOfParallelism = 6 });
n = 0;
foreach (var a in list)
block.Post(a);
block.Complete();
block.Completion.Wait();
if (n != list.Count)
ShowError(); //it's called sometimes
}