Exemple #1
0
        public async Task TestProxy()
        {
            if (this.proxies == null)
            {
                return;
            }

            if (proxyListWorked == null)
            {
                proxyListWorked = new ObservableCollection <Proxy>();
            }

            await Task.Run(() =>
            {
                Parallel.ForEach(proxies, new ParallelOptions {
                    MaxDegreeOfParallelism = maxParallelTask
                }, async proxy =>
                {
                    var p      = new Proxy(proxy);
                    var client = new Classes.Client(p, this.myIp);

                    try
                    {
                        await client.TestProxy();
                        proxyListWorked.Add(p);
                    }
                    catch (System.NullReferenceException) { }
                });
            });
        }
Exemple #2
0
        public async Task <bool> TestOneProxy(string proxy)
        {
            return(await Task.Run(async() =>
            {
                var p = new Proxy(proxy);
                var client = new Classes.Client(p, this.myIp);

                try
                {
                    await client.TestProxy();

                    return true;
                }
                catch (System.NullReferenceException)
                {
                    return false;
                }
            }));
        }