0
술어를 사용하여 TransformBlock에서 ActionBlock으로 전달 된 항목을 필터링 할 때 완료되지 않는 다음 TPL Dataflow가 있습니다.술어를 사용할 때 TPL 데이터 흐름이 완료되지 않음
조건부가 항목에 대해 false를 반환하면 데이터 흐름이 중단됩니다.
누군가가 어떤 일이 일어나고 있는지, 어떻게 해결할 수 있는지에 대한 통찰력을 제공 할 수 있습니까?
// define blocks
var getBlock = new TransformBlock<int, int>(i =>
{
Console.WriteLine($"getBlock: {i}");
return ++i;
});
var writeBlock = new ActionBlock<int>(i =>
{
Console.WriteLine($"writeBlock: {i}");
});
// link blocks
getBlock.LinkTo(writeBlock, new DataflowLinkOptions
{
PropagateCompletion = true
}, i => i == 12); // <-- this predicate prevents the completion of writeBlock
// push to block
var items = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
foreach (var i in items)
{
getBlock.Post(i);
}
// wait for all operations to complete
getBlock.Complete();
await writeBlock.Completion; // <-- application hangs here