I am working on an Android application, backed up by an ASP.NET Core application hosted on Azure. I am using a shared Library project to test basic stuff on a Console Applic
It seems like you are experiencing a deadlock of some sort. You might want to include the code where you actually call GetInformationAsync, as it is probably where the problem source is.
You can probably fix your issue by:
GetInformationAsync in a sync wayGetInformationAsync with ConfigureAwait(false) to not switch context on every method call.So your GetInformationAsync method would look like:
public static async Task<MyClass> GetInformationAsync(string accountId)
{
var response = await Client.GetAsync(UriData + "/" + accountId).ConfigureAwait(false);
response.EnsureSuccessStatusCode();
var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
return JsonConvert.DeserializeObject<MyClass>(responseContent);
}
Then if you call it somewhere you need it to return back on the same context, I.e. if you need to update UI:
var myClass = await GetInformationAsync(accountId);
// update UI here...
Otherwise if you don't need to return on the same context:
var myClass = await GetInformationAsync(accountId).ConfigureAwait(false);