Skip to content

Instantly share code, notes, and snippets.

@darsen
Created April 5, 2023 19:54
Show Gist options
  • Save darsen/9a25219d2f286d9424da5eb1a4e60c29 to your computer and use it in GitHub Desktop.
Save darsen/9a25219d2f286d9424da5eb1a4e60c29 to your computer and use it in GitHub Desktop.
using Simple.HttpClientFactory;
using Simple.HttpClientFactory.MessageHandlers;
using System;
using System.Net.Http;
namespace HttpClientFactory472
{
internal class Program
{
//use static handler to reuse ports
static HttpClientHandlerEx handler = new HttpClientHandlerEx();
static void Main(string[] args)
{
for (int x = 0; x < 100; x++)
{
HttpClient client = HttpClientFactory.Create()
//provide handler to factory
.Build(handler);
HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "http://www.google.com");
var result = client.SendAsync(message).Result;
Console.WriteLine(result.StatusCode);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment