When I make this same call through the emulator, passing as a parameter a higher limit, consequently the json will be higher, this error is shown, but if the limit is lower and the json smaller, it does not show the error.
And by my physical cell phone the error is not disassembling at any time
Error: not met, function:get_this_async_id, Could not execute the method because the containing type 'System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult_REF]', is not fully instantiated. assembly: type: member:(null)
I'm using the polly library to make http calls
my code
public async Task<Hero> GetHeroesWichFactory(string limite)
{
var func = new Func<Task<Hero>>(() => HeroGetRequest(limite));
//main function
return await _networkService.WaitAndRetry<Hero>(func, new Func<int,
TimeSpan>(time => TimeSpan.FromSeconds(Math.Pow(2, time))), 3);
}
async Task<Hero> HeroGetRequest(string limite)
{
var httpClient = new HttpClient();
var response = await httpClient.GetAsync(GetUrl(limite));
var rawResponse = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<Hero>(rawResponse);
}
public async Task<T> WaitAndRetry<T>(Func<Task<T>> func, Func<int, TimeSpan> sleepDurationProvider, int retryCount)
{
return await WaitAndRetryInner<T>(func, sleepDurationProvider, retryCount);
}
internal async Task<T> WaitAndRetryInner<T>(Func<Task<T>> func, Func<int, TimeSpan> sleepDurationProvider, int retryCount = 1, Func<Exception, TimeSpan, Task> onRetryAsync = null)
{
var onRetryInner = new Func<Exception, TimeSpan, Task>((e, t) =>
{
return Task.Factory.StartNew(() => {
System.Diagnostics.Debug.WriteLine($"Retrying in {t.ToString("g")} due to exception '{(e.InnerException ?? e).Message}'");
});
});
return await Policy.Handle<Exception>().WaitAndRetryAsync(retryCount, sleepDurationProvider, onRetryAsync ?? onRetryInner).ExecuteAsync<T>(func);
}
note: sometimes the error stops happening in the emulator, and suddenly comes back, without having had any changes in the code
accept code suggestion please, this is the repository https://github.com/gabriel-projetos/AppMarvel
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…