The original error is that the overload resolution failed. Then the C# compiler has some heuristics that try to figure out why the overload resolution failed, and in this case those heuristics didn't tell you the "correct" cause.
First look at the available two parameter overloads:
public ActionBlock(Action<TInput> f, ExecutionDataflowBlockOptions o);
public ActionBlock(Func<TInput, Task> f, ExecutionDataflowBlockOptions o);
The second parameter is ExecutionDataflowBlockOptions
in both cases. But you supply a DataflowBlockOptions
which is a base class of ExecutionDataflowBlockOptions
. Since base classes are not implicitly convertible to derived classes the overload resolution fails. Once you create the correct kind of options, your code will work.
A related answer of Eric Lippert on compiler-error heuristics when overload resolution fails: Passing lambda functions as named parameters in C#