In my WPF applciation, my ViewModel, talks to a ViewModelService, which in turn talks to say for example a CalculationService to retrieve processed data to be presented in the View. I would like for the view to be able to report percentage of completion to the user. My question is two fold.
The first is where should this logic reside? Should the CalculationService be tasked with reporting progress along with the actual results or does the ViewModel service calculate the progress percentage details.
Second, I see that I can achieve this using TPL or using ReactiveExtentions. Am leaning towards reactive extentions becuase in my case, the calculation service's API and implementation looks like this
//This is pseudo code, just aiming to show my intention here
IEnumerable<Output> Calculate(IEnumerable<Inputs> inputs){
List<Output> output = new List<Output>();
foreach(var input : inputs){
//long running calculation, which produces output
//outputs.Add(output)
}
}
Am assuming that if I go down the Reactive route, I can use Reactive's OnNext to stream the "Output", as they arrive and I also can use Parallel.Foreach to gain performance.
Any ideas or thoughts on this?
Thanks Kay