Where to put heavy init operations in MvvmCross

mvvmcross, xamarin

Solution

I would do heavy stuff in a `Service`. In that service i would either:

- Make a method which triggers a `Done` event which you can listen for in your `ViewModel` and from there populate Properties with data.

or

- Make an async method which you await on a background thread and when it returns you populate Properties.

While this service runs and fetches data, I would simply display something else on the screen, while the data loads. This could be some cached data or a progress bar or something else.

Problem

In an MvvmCross ViewModel, the Init method is used for any screen initialization. However, the screen is not drawn until Init is fully completed. I have some heavy operations (db searching). So ideally I would like to draw the screen with a progress bar, and then run my initialization methods, and finally update the screen. Where would I put these operations in the MvvmCross ViewModel?

Original source