So I have an app that is retrieving web information. After I get this information I need to process the object returned (A JSON string). However, as far as I can tell, my program keeps breaking as when the web info is awaiting, it jumps into the next processing stage, which has no data to process, therefore breaks. How can I go about fixing it?
Here is the async method
async private Task GetInformation(string url)
{
client = new HttpClient();
response = await client.GetAsync(new Uri(url));
result = await response.Content.ReadAsStringAsync();
}
As mentioned below, I should have put await infront of the location where I am calling GetInformation, however, that method is used to return a string to another class like so
public string GetResult(string url)
{
GetInformation(url);
return result;
}
How can I fix this?
Thanks for any help