В следующем (упрощенном) коде вызов GetLocation просто зависает в отладчике и никогда не доходит до следующего «еще одного кода». Что я делаю не так?
namespace abc
{
public partial class Form1 form
{
public Form1
{
...
}
private OnSomeButtonClicked
{
/* some code */
Task taskRes = GetLocation(ap.Latitude, ap.Longitude);
string[] loc = taskRes.Result;
/* some more code */
}
private async Task GetLocation(double lat, double lon)
{
string url = $"https://api.geoapify.com/v1/geocode/rev ... ey={apiKey}";
string result;
using (HttpClient client = new HttpClient())
{
HttpResponseMessage response = await client.GetAsync(url);
if (!response.IsSuccessStatusCode)
{
throw new HttpRequestException($"Geoapify client.GetAsync request failed with status code {response.StatusCode}");
}
result = await response.Content.ReadAsStringAsync();
}
return res;
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... a-response