I'm currently developing in WPF / MVVM following the dataservice pattern where ViewModel call a Service that contains all the business objects and method.
Now, when I call the service method, this requires a bit of time so I should create a new Task in order to let the GUI not freezed.
In your opinion, where is the best location to start a task, in the ViewModel or in the Service itself?
...
// TaskFactory.StartNew(() => {}); // where I should put this ? *
...
class DataService
{
MyBussObj mbo;
CallBusinessOperation()
{
// * here ?
while (mbo.Next())
{
// requires a while
}
}
}
class MyViewModel
{
DataService service = new DataService();
void DoIt()
{
// * here ?
service.CallBusinessOperation();
}
}