WebBrowser多次请求页面

  private void AutoRefresh()

        {

            WebBrowser webBrowser = new WebBrowser();

            webBrowser.Navigated += new WebBrowserNavigatedEventHandler(webBrowser_DocumentCompleted);



            while (1 == 1)

            {

                if (HasRun)

                {

                    Loadflag = true;

                    Thread.Sleep(5000);



                    webBrowser.Navigate(Core.urlstr);



                    while (Loadflag)

                        Application.DoEvents();

                }

                else

                    break;

            }

            //thread.Abort();



        }
 private void webBrowser_DocumentCompleted(object sender, WebBrowserNavigatedEventArgs e)

        {

            //webBrowser1.Refresh();

            WebBrowser webtemp = (WebBrowser)sender;

            var txt = new StreamReader(webtemp.DocumentStream).ReadToEnd();

            LogicLog(txt);

            Loadflag = false;

        }

 

你可能感兴趣的:(WebBrowser)