如何使用Button激活此代码?

时间:2015-09-10 20:01:01

标签: c#

正如标题所说。我想在FormsApp中使用按钮激活此代码,但我真的不知道如何操作。

  public static async Task<List<string>> GetProxiesFromSslProxies()
    {
        try
        {
            string rssContent = await new WebClient().DownloadStringTaskAsync("http://sslproxies24.blogspot.de/feeds/posts/default");
            XDocument feed = XDocument.Parse(rssContent);
            SyndicationFeed sf = SyndicationFeed.Load(feed.CreateReader());

            List<string> allProxies = new List<string>();
            foreach (SyndicationItem si in sf.Items)
            {
                var cont = (TextSyndicationContent) si.Content;
                var matches = Regex.Matches(cont.Text, @"\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}:[0-9]{2,6}\b");
                allProxies.AddRange(from Match match in matches select match.Value);
            }
            return allProxies.Distinct().ToList();
        }
        catch (Exception)
        {

        }
        return null;
    }

0 个答案:

没有答案