-
-
Save dcomartin/203b73b0d64099d5196c07a278e077c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Polly; | |
var pipeline = new ResiliencePipelineBuilder<HttpResponseMessage>() | |
.AddConcurrencyLimiter(permitLimit: 10, queueLimit: 100) | |
.Build(); | |
var httpClient = new HttpClient(); | |
await Parallel.ForEachAsync(Enumerable.Range(0, 10).ToArray(), async (i, _) => | |
{ | |
var response = await pipeline.ExecuteAsync<HttpResponseMessage>(async _ => await httpClient.GetAsync("https://google.ca")); | |
Console.WriteLine($"Iteration: {i}, Response: {response.StatusCode}"); | |
}); | |
Console.WriteLine("Done"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment