Forum Xamarin.Forms

I am getting warning from main thread.

I have many apis calls in a single page. The approach i am currently using is start a await Task.Run(() thread, do fetch operation, start Main Thread and do UI operations. The app works smooth but after few navigation, it stops responding. With some research it found thus can be due to main thread. Is this the correct way implementation, that i am using?

 await Task.Run(() =>
                {
fetchdata();
fetchData2();
fetchData3();

MainThread.BeginInvokeOnMainThread(() =>
                    {

//UI changes
}:

});

Best Answers

  • daalboodaalboo ✭✭
    Accepted Answer

    This issue was resolved using http client instead of web request. Thanks to JohnHardnan.

Answers

  • JoeMankeJoeManke USMember ✭✭✭✭✭

    What exactly do you mean by "UI changes"? Are you using bindings to display your data?

  • daalboodaalboo Member ✭✭

    Here is code behind the homepage.

  • daalboodaalboo Member ✭✭

    I see similar issues like below.
    https://github.com/mono/SkiaSharp/issues/998

  • daalboodaalboo Member ✭✭
    Accepted Answer

    This issue was resolved using http client instead of web request. Thanks to JohnHardnan.

Sign In or Register to comment.