MvvmCross: MvxCommand(async () => await ...) blocking UI
I have a ViewModel with the following code
 public IMvxCommand LoginCommand => new MvxCommand(async () => await LoginClicked());
 private async Task LoginClicked()
 {
     //.....
 }
Which has a couple of seconds (depending on how old the device is) delay once I click on the button, ultimately blocking the UI. (I have tried the above written in multiple ways).
However when I change the code to the following, then there are absolutely no delays.
public IMvxCommand LoginCommand => new MvxCommand(LoginClicked);
private void LoginClicked()
{
    Task.Run(async () => await Login());
}
Obviously I prefer the above option, but it causes bad user experience. I have only had the option to try this on Xamarin.Android so far, will shortly test it on iOS and WP.
using
- MVVMCross 4.0.0-beta7
- Latest Xamarin
- VS2015.1
- Android 5.1
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 24 (13 by maintainers)
That would be because I havent RTFM! I’ll report back!