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

前端 未结 1 548
孤城傲影
孤城傲影 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)
提交回复
热议问题