I have the following in C#
public static void Main()
{
var result = Foo(new Progress(i =>
Console.WriteLine(\"Progress: \" + i)));
As pointed out several times before by other answers, it's due to how Progress
is implemented. You could provide your clients (users of the library) with example code, or an implementation of IProgress
for a console project. This is basic, but should do.
public class ConsoleProgress : IProgress
{
private Action _action;
public ConsoleProgress(Action action) {
if(action == null) {
throw new ArgumentNullException(nameof(action));
}
_action = action;
}
public void Report(T value) {
_action(value);
}
}