webBrowser.Navigate synchronously

前端 未结 2 1160
长发绾君心
长发绾君心 2021-01-19 23:46

i want to call webBrowser.Navigate(string urlString) synchronously where webBrowser is windows forms control. I do this in such way

...
private delegate void         


        
相关标签:
2条回答
  • 2021-01-19 23:54

    Rather use this to retrieve the page syncronously:

    this.webBrowser.DocumentCompleted += WebBrowserDocumentCompleted;
    this.webBrowser.Navigate("http://google.com");
    
    private void WebBrowserDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
      MessageBox.Show("Operation has completed !");
    }
    
    0 讨论(0)
  • 2021-01-19 23:59

    Not the best way, but you can use this...

    while (this.webBrowser.ReadyState != WebBrowserReadyState.Complete)
    {
         Application.DoEvents();
         Thread.Sleep(100);
    }
    
    0 讨论(0)
提交回复
热议问题