Is it possible to pass IProgress<T> from js client to the C# SignalR hub? What I'm trying to do is:
On the hub side:
public class ProgressHub : Hub<IProgressHub>
{
public async Task Foo(string jobId, IProgress<int> progress)
{
Console.WriteLine($"Started monitoring {jobId}");
for (int i = 0; i < 100; i++)
{
await Task.Delay(TimeSpan.FromSeconds(1)); // Simulate some work
progress.Report(i);
}
}
}
public interface IProgressHub
{
Task Foo(string jobId, Progress<int> progress);
}
On the js side:
connection
.invoke("Foo", "this-is-job-id", progressPercentage => console.log(`Processed ${value}%`))
.then(() => console.log("Processing done"));
The method on signalr hub gets called, but IProgress always ends up being null.