webBrowser.Navigate同步 [英] webBrowser.Navigate synchronously
本文介绍了webBrowser.Navigate同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要打电话webBrowser.Navigate(字符串urlString)同步,其中web浏览器是Windows窗体控件。我这样做是在这样的方式
i want to call webBrowser.Navigate(string urlString) synchronously where webBrowser is windows forms control. I do this in such way
...
private delegate void NavigateDelegate(string s);
...
private void Function()
{
NavigateDelegate navigateDelegate =
new NavigateDelegate(this.webBrowser1.Navigate);
IAsyncResult asyncResult =
navigateDelegate.BeginInvoke("http://google.com", null, null);
while (!asyncResult.IsCompleted)
{
Thread.Sleep(10);
}
MessageBox.Show("Operation has completed !");
}
但邮件永远不会推。为什么这code不能正常工作?
but message is never shoved. WHY this code doesn't work properly?
推荐答案
而使用这个检索页面的 syncronously 的:
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 !");
}
这篇关于webBrowser.Navigate同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文