Skip to content

Instantly share code, notes, and snippets.

@darrelmiller
Created March 11, 2014 13:41
Show Gist options
  • Save darrelmiller/9485825 to your computer and use it in GitHub Desktop.
Save darrelmiller/9485825 to your computer and use it in GitHub Desktop.
class Program
{
static void Main(string[] args)
{
ServicePointManager.DefaultConnectionLimit = 2;
var tasks = new Task[10];
for (int i = 0; i < 10; i++)
{
tasks[i] = Run();
}
Task.WhenAll(tasks).Wait();
using (HttpClient client = new HttpClient())
{
for (int i = 0; i < 10; i++)
{
tasks[i] = Run(client);
}
Task.WhenAll(tasks).Wait();
}
}
private static async Task Run()
{
HttpClient client = new HttpClient();
var response = await client.GetAsync("http://www.tugberkugurlu.com");
}
static async Task Run(HttpClient client)
{
var response = await client.GetAsync("http://www.tugberkugurlu.com");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment