UIKit.UIKitThreadAccessException: UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread

前端 未结 1 549
孤城傲影
孤城傲影 2021-01-26 13:07

I\'m trying to run this code:

GetRepsButton.Command = new Command(async () =>
            {
                var url = @\"https://url\";

                HttpC         


        
1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-26 13:30

    Use Device.BeginInvokeOnMainThread

    Device.BeginInvokeOnMainThread(() =>
    {
      //your code
    });
    

    https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.device.begininvokeonmainthread?view=xamarin-forms

    0 讨论(0)
提交回复
热议问题