0

I am trying to do async with sql lite and Xamarin by following this tutorial

https://learn.microsoft.com/en-us/learn/modules/store-local-data-with-sqlite/6-exercise-use-sqlite-asynchronously

enter image description here

when I do this the whole app stops responding why ?

statusMessage.Text = "";
var people = App.PersonRepo.GetAllPeopleAsync();
peopleList.ItemsSource = people;

enter image description here

Micah Armantrout
  • 6,781
  • 4
  • 40
  • 66
  • you need to use await when making an async call. `var people = await App.PersonRepo.GetAllPeopleAsync();` – Jason Apr 01 '20 at 18:07
  • thanks for the reply .... I am see definition of GetAllPeopleAsync() in attached screenshot. does that need to be done in the UI as well ? When I put it there I get a error – Micah Armantrout Apr 01 '20 at 18:14
  • https://stackoverflow.com/questions/14455293/how-and-when-to-use-async-and-await – Jason Apr 01 '20 at 18:16
  • Jason I figured it out and you were correct I just didn't fully understand your answer. you want to post a answer and I will accept it Thanks! – Micah Armantrout Apr 01 '20 at 21:25

1 Answers1

1

you need to use await when calling an async method

var people = await App.PersonRepo.GetAllPeopleAsync()
Jason
  • 86,222
  • 15
  • 131
  • 146