I would like to perform (4-5) background Json parsing from web. I've got class with static method:
EventsSingleton.GetPlaces();
Which return list. That's working so far. When I try to async all the operations:
public async Task<List<Places>> Test()
{
var myTask = Task.Run(() => Test2());
List<Places> result = await myTask;
return result;
}
public List<Places> Test2()
{
List<Places> listatest = EventsSingleton.GetPlaces();
for (int i = 0; i <= 50; i++)
{
progressBar5.Dispatcher.Invoke(() => progressBar5.Value = i, DispatcherPriority.Background);
}
return listatest;
}
Everything is still ok by now, correctly returning list and setting progressbar. Problem came out when I tried to return that value to my page contructor (or to OnClickButton method). I'm trying to do:
var list5 = Test().Result;
But after compilation my program doesn't even start. I thing that my list isn't prepared yet, but maybe that "await" should do the job?