I have a problem.
I created an Android page with some buttons and a GridView. Now the GridView gets filled with a json from my website and I want to reload the GridView every 3 seconds, without slowing down the app!!! So I tried this:
In the Page1 load void:
RunOnUiThread(() => LoadOrdersAsync());
And the function:
public async Task LoadOrdersAsync()
{
while (true)
{
//Creating SortedList
if (OrderListAdapter == null)
{
//Fill the DataSource of the ListView with the Array of Names
OrderListAdapter = new OrderListAdapter(this, SortedOrderList);
GridviewOrders.Adapter = OrderListAdapter;
}
else
{
OrderListAdapter.refresh(SortedOrderList);
}
// don't run again for at least 3 seconds
await Task.Delay(3000);
}
}
The problem is that everything get's filled, but the UI is lagging, because of that thread. How can I fix this problem?