I am trying to master async method syntax in .NET 4.5. I thought I had understood the examples exactly however no matter what the type of the async method is (ie Task
You need to make TestGetMethod async too and attach await in front of GetIdList(); will unwrap the task to List, So if your helper function is returning Task make sure you have await as you are calling the function async too.
public Task> TestGetMethod()
{
return GetIdList();
}
async Task> GetIdList()
{
using (HttpClient proxy = new HttpClient())
{
string response = await proxy.GetStringAsync("www.test.com");
List idList = JsonConvert.DeserializeObject>();
return idList;
}
}
Another option
public async void TestGetMethod(List results)
{
results = await GetIdList(); // await will unwrap the List
}