我正在使用TPL DataFlow和ActionBlock来创建并行性。我不确定我做错了什么似乎无休止地等待
string ret = string.Empty;
var actionBlock = new ActionBlock<string>(async method =>
{
ret = await asyncall(param);//method not shown for brevity
}, //Stepped through till here
new ExecutionDataflowBlockOptions
{
MaxDegreeOfParallelism = Environment.ProcessorCount
});
actionBlock.Post("123");
actionBlock.Complete();
await Task.WhenAll(actionBlock.Completion);
return ret;
当单步执行代码时,我可以将其跟踪到我在上面的代码中添加注释的位置。完成actionblock后,应用程序继续无助地等待IsCompleted为false。