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) { } }); }); }
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; } })); }