Created
April 5, 2023 19:54
-
-
Save darsen/9a25219d2f286d9424da5eb1a4e60c29 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 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