Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal class Program
- {
- private static void Main(string[] args)
- {
- var urls = new[]
- {
- "https://httpbin.org",
- "https://httpbin.org/get",
- "https://httpbin.org/ip"
- };
- var results = DownloadAsync(urls).Result;
- foreach (var result in results)
- {
- Console.WriteLine(result);
- }
- }
- private static async Task<string[]> DownloadAsync(IEnumerable<string> urls)
- {
- var settings = new ProxySettings
- {
- Host = "127.0.0.1",
- Port = 1080
- };
- using (var client = new HttpClient(new ProxyClientHandler<Socks5>(settings)))
- {
- var tasks = urls.Select(url => client.GetStringAsync(url));
- return await Task.WhenAll(tasks).ConfigureAwait(false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement