I'm wondering what is a best practice to handle processing a collection of items and display the progress back to the UI.
The following code is roughly what I wrote to handle it, but it seems quite dirty:
Command = ReactiveCommand.CreateAsyncTask(_ => {
return Task.Run(() =>
{
Parallel.ForEach(items, item =>
{
RunSlowProcess(item);
Application.Current.Dispatcher.BeginInvoke(x =>
{
Progress += 1;
}
});
}
}
Is there some major concept of ReactiveUI that I'm missing?
It seems a bit confusing because of all the parallel patterns are mixed together here:
I would suggest something more like (untested):