I am working on a Winforms app that makes some HTTP based API calls to various web services within a Timer control loop. The web services are called using the async keyword. The problem is that I get a Threading exception when attempting to return the result as a string.
private async Task<String> UpdateViaApi(ClientInfoObject clientInfoObject)
{
HttpResponseMessage response = await myHttpClient.SendAsync(request);
string result = await response.Content.ReadAsStringAsync();
return result;
}
Here is how I call the method ...
string result = UpdateViaApi(clientInfoObject);
The ClientInfoObject is a simple class that contains data as a series of properties. Am I using Task properly?
Task<string>not a string.