DEV Community

Discussion on: How we Added Auto-Retries to our C# API Client

Collapse
manigandham profile image
Mani Gandham

LINQ uses lazy evaluation so uniqueExceptions in the last example will be enumerated and processed for distinct elements 3 times - for the .Count(), .First() and the final return. You should just call .ToList() after .Distinct() to get an actual List of exceptions.

There's also the Polly library which handles retries, timeouts, circuit breakers and many other resiliency situations in a well built API.

github.com/App-vNext/Polly