How to call an async
method into a method that implements an interface when this method is NOT async
?
In my ViewModel, I've got an async
method that should be executed each time the user navigates into the view.
The fastest (bad) solution I was able to find is this one
public class MyViewModel : INavigationAware
{
//[...]
public async void OnNavigatedTo(NavigationContext navigationContext)
{
await Refresh();
}
public async Task Refresh()
{
await Task.Run(() =>
{
// Asynchronous work
});
/* Actions on Gui Thread */
}
//[...]
}