Asynchronous method to update UI element in Xamarin
I got an app to call api in my server for loading the data. This make sense to use asynchronous methods for loading the data. I don't want the whole UI is locked for waiting the data. But I found
model.GetData().ContinueWith((items) =>
{
list.ItemSource= items;
});
It won't works. I found the reason is all Asynchronous methods are executed by a different thread. You have to call UI main thread to bind the data to UI.
model.GetData().ContinueWith((items) =>
{
evice.BeginInvokeOnMainThread(() =>
{
list.ItemSource= items;
});
});;
Trackback address for this post
Trackback URL (right click and copy shortcut/link location)
Feedback awaiting moderation
This post has 7 feedbacks awaiting moderation...
Form is loading...