I would like to perform a certain operation, and if it fails three times return null. Something like this in Polly would be perfect:
var results = await Policy<IList<Value>>
.Handle<TaskCanceledException>()
.RetryAsync<IList<Value>>(3)
.FallbackAsync(null as IList<Value>)
.ExecuteAsync(() => myRestfulCall());
This isn't possible as RetryAsync
returns an AsyncRetryPolicy
and there is no Fallback extension method defined on this type. Is there a Polly syntax to do this that doesn't require a try/catch block?
await
before the call toWrapAsync
, but thank you that's exactly what I was missing. – Glyptograph