In Short
I create an BatchBlock which links to an ActionBlock, which calls a async method, but this method never fires.
Details
Here is how I create the blocks
var instance = new ConnectionSaveStep(repo, progress, total);
var batch = new BatchBlock<LandingPageConnection>(10000);
saveAction = new ActionBlock<IEnumerable<LandingPageConnection>>(i => instance.Save(i));
batch.LinkTo(saveAction);
The save method looks like this:
internal async Task Save(IEnumerable<LandingPageConnection> pages)
{
Trace.WriteLine("Inserting " + pages.Count() + " items ...");
await repo.InsertBatchAsync(pages);
}
Elements (about 1 mio) are queued within a Parallel.ForEach
.
Parallel.ForEach(cities, city=>
{
var pages= BuildLandingPage(city);
batch.Post(pages);
but the save Method gets never raised
When I've a look at the property of the batch and saveAction I can see that first the number of the items in the unput queue of the batch block is increasing till it reaches the batchblock size. After that one item with 10.000 work items is queued in the saveACtion input queue .
But the save is never called.
What am I doing wrong?