如何从网站获得快速响应 [英] How to get fast response from a website

查看:68
本文介绍了如何从网站获得快速响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好......

我有一个htmltags(Links)的列表视图.我想从该列表视图的每个项目中获取答复.

当我开始循环时,我的UI没有响应.
我的代码是..

Hi Everyone....

I have a listview of htmltags(Links). I want to get response from every item of that listview .

when I start looping then my UI was not responding .
My code is..

foreach (ListViewItem list in listView1.Items)
           {
               bool respond = checkrequest(list.Text);
               if (respond == true)
                   Do something......
               else others......
           }







public bool checkrequest(string url)
        {
            try
            {
                WebRequest webrequest =HttpWebRequest.Create(url);
                WebResponse webresponse;
                try
                {
                    webresponse = (HttpWebResponse)webrequest.GetResponse();
                }
                catch (Exception)
                {
                    return false;
                }
            }
            catch 
            {               
            }
            return true;
        }



IT需要太多时间才能做出响应.超时发生异常.

我如何才能使我的UI保持活力?并使从任何网站获取Respose的程序变得更快.


谢谢



IT takes too much time to get respond . Exception occur for Timeout .

how can i make my UI alive ? and make my program faster of getting Respose from any website .


Thank You

推荐答案

您必须异步执行操作才能使UI保持响应.
看看任务并行库 [
You have to execute your operations asynchronous in order to keep your UI responsive.
take a look at the Task Parallel Library[^]


这篇关于如何从网站获得快速响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆