Ejemplo n.º 1
0
        public static async Task TestProxies(List <Access> access)
        {
            List <Task> tasks = new List <Task>(access.Count);

            access.ForEach(a =>
            {
                tasks.Add(Task.Run(() =>
                {
                    Console.WriteLine(DateTime.Now.ToString() + "]Start ip " + a.Proxy);
                    var restClient = HttpHelper.InitRestClient(a, "https://api.ipify.org/");
                    ProxyHelper.TestProxy(restClient, a.Proxy);
                }));
            });
            await Task.WhenAll(tasks);

            Console.WriteLine(DateTime.Now.ToString() + "]all tasks complete");
        }
Ejemplo n.º 2
0
        public static async Task TestProxies(List <Access> access)
        {
            var tasks      = new List <Task <bool> >();
            var restClient = new RestClient("https://api.ipify.org/");

            foreach (var a in access)
            {
                HttpHelper.InitRestClient(a, restClient);
                tasks.Add(ProxyHelper.TestProxy(restClient, a.Proxy));
            }
            await Task.WhenAll(tasks);

            for (int i = 0; i < access.Count; i++)
            {
                access[i].Ok = tasks[i].Result;
            }
        }