Created
July 16, 2018 11:59
-
-
Save dataneek/494e57ec7463420c43eacad3b720193d to your computer and use it in GitHub Desktop.
Example use of HttpClient - before and after.
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
namespace ConsoleApplication | |
{ | |
public class Program | |
{ | |
private static HttpClient client = new HttpClient(); | |
public static async Task Main(string[] args) | |
{ | |
Console.WriteLine("Starting connections"); | |
for(int i = 0; i<10; i++) | |
{ | |
var result = await client.GetAsync("http://neekgreen.com"); | |
Console.WriteLine(result.StatusCode); | |
} | |
Console.WriteLine("Connections done"); | |
} | |
} | |
} |
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
namespace ConsoleApplication | |
{ | |
public class Program | |
{ | |
public static async Task Main(string[] args) | |
{ | |
Console.WriteLine("Starting connections"); | |
for(int i = 0; i<10; i++) | |
{ | |
using(var client = new HttpClient()) | |
{ | |
var result = await client.GetAsync("http://neekgreen.com"); | |
Console.WriteLine(result.StatusCode); | |
} | |
} | |
Console.WriteLine("Connections done"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment