Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Refreshing ListView Content with Async Task - ArgumentOutOfRange Exception - What am I doing wrong?

$
0
0

Hello!

I have a ListView (defined in XAML), with a Cell Layout (also defined in XAML) and what I am doing is that I have a Task running that fills the ListView as soon as its finished.

async void ButtonClick (Button sender) {
MyCommunication sc = new MyCommunication();
Task<List> myTask = sc.getMyClassList();
List myObjList = await myTask;
myList.ItemsSource = myObjList;
}

now.. when I am doing the monkey test - i.e. click like a mad man on the button, i very easily get into the "ArgumentOutOfRangeException" (ListView..)

My wild guess is that I refresh the ListView with new Data when I Click a Cell at the same time...
What I did now to prevent that:

async void ButtonClick (Button sender) {
** myList.isEnabled=false;**
MyCommunication sc = new MyCommunication();
Task<List> myTask = sc.getMyClassList();
List myObjList = await myTask;
myList.ItemsSource = myObjList;
myList.isEnabled=true;
}

Did not help... it actually seems like isEnabled does not work at all?

I am currently only working on iOS - if thats important anyhow.

Thanks for your help!


Viewing all articles
Browse latest Browse all 58056

Trending Articles