private void exportWorkingProxies_Click(object sender, EventArgs e) { if (exportWorkingProxiesSaveDialog.ShowDialog() == DialogResult.OK) { Stream filestream; if ((filestream = exportWorkingProxiesSaveDialog.OpenFile()) != null) { using (StreamWriter writer = new StreamWriter(filestream)) { List <WebProxy> workingProxies = new List <WebProxy>(proxiesChecked.Where( kv => kv.Value == ProxyCheckResult.OK ).ToDictionary(x => x.Key, x => x.Value).Keys); writer.Write(ProxyListParser.ToProxyList(workingProxies)); } filestream.Close(); } } }
private async void proxyFileDialog_FileOk(object sender, CancelEventArgs e) { Stream filestream = proxyFileDialog.OpenFile(); using (StreamReader reader = new StreamReader(filestream)) { List <WebProxy> proxies = ProxyListParser.ToWebProxy(reader.ReadToEnd()); Console.WriteLine("Proxy list selected. ({0}) proxies", proxies.Count); Progress <ProxyCheckProgressReport> progress = new Progress <ProxyCheckProgressReport>(); progress.ProgressChanged += proxyFileProgress_ProgressChanged; cancellationToken = new CancellationTokenSource(); changeRunningState(ProxyCheckerState.Running); proxiesChecked = new Dictionary <WebProxy, ProxyCheckResult>(); await ProxyChecker.CheckProxiesAsync(proxies, targetWebsite.Text, (int)timeoutThreshold.Value, progress, cancellationToken.Token); changeRunningState(ProxyCheckerState.Finished); } }