我要打电话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 !");
}