7
A
回答
11
使用过程中的定时器超时。例如:
public void NavigateTo(Uri url) {
webBrowser1.Navigate(url);
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e) {
timer1.Enabled = false;
MessageBox.Show("Timeout on navigation");
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
if (e.Url == webBrowser1.Url && timer1.Enabled) {
timer1.Enabled = false;
// etc..
}
}
0
我使用基于Navigating
和Navigated
事件下面的方法。观察这两次事件之间的时间重定向到家庭pgae。
//Navigation Timer
timer2.Enabled = true;
timer2.Interval = 30000;
br.DocumentCompleted += browser_DocumentCompleted;
br.DocumentCompleted += writeToTextBoxEvent;
br.Navigating += OnNavigating;
br.Navigated += OnNavigated;
br.ScriptErrorsSuppressed = true;
br.Navigate(ConfigValues.websiteUrl);
private void OnNavigating(object sender, WebBrowserNavigatingEventArgs e)
{
//Reset Timer
timer2.Stop();
timer2.Start();
WriteLogFunction("OnNavigating||||||"+e.Url.ToString());
}
private void OnNavigated(object sender, WebBrowserNavigatedEventArgs e)
{
//Stop Timer
timer2.Stop();
WriteLogFunction("NAVIGATED <><><><><><><> " + e.Url.ToString());
}
private void timer2_Tick(object sender, EventArgs e)
{
WriteLogFunction(" Navigation Timeout TICK");
br.Stop();
br.Navigate(ConfigValues.websiteUrl);
}
参考
+0
那么br.Stop()会导致Web浏览器控件停止尝试导航? – crush 2017-12-14 03:03:05
相关问题
- 1. C#Web浏览器导航
- 2. Web浏览器控件未注册导航事件
- 3. WPVM Web浏览器的MVVM导航事件
- 4. IdentityServer3替代Web浏览器导航事件
- 5. WPF触发器web浏览器导航/导航中
- 6. 是为每个导航方法多次触发的浏览器导航事件?
- 7. 如何隐藏浏览器导航?
- 8. 如何正确处理Web浏览器控制返回导航
- 9. 导航浏览器转到
- 10. 从FireBreath插件拦截浏览器导航事件
- 11. Web浏览器控件在导航时抛出NullReferenceException
- 12. C#Web浏览器控件:导航到列表到URL
- 13. Web浏览器控件 - 一个接一个地导航到URL
- 14. Web浏览器未触发DocumentCompleted事件
- 15. wp7浏览器导航事件没有触发
- 16. 如何删除在浏览器控件中导航的文件?
- 17. Web浏览器控件:如何捕获文档事件?
- 18. 如何检测事件是否为浏览器事件
- 19. 如何从Web浏览器
- 20. SWT浏览器导航器版本
- 21. .NET Web浏览器控件 - 另存为事件
- 22. 如何在Web浏览器中启用触摸事件模拟?
- 23. 为什么此背景浏览器控件无法导航?
- 24. Web浏览器作为Web服务器
- 25. 即使设置DocumentStream,web浏览器也不会导航?
- 26. Web浏览器在XNA 4.0中没有导航
- 27. 是否可以确定Web浏览器是否正在导航?
- 28. WP8 Web浏览器,停止导航而不会造成页面
- 29. HTML5为C#Web浏览器
- 30. Web浏览器的导航器(Chrome的HTML文件名(.htm))使用C#
那不是等待web浏览器来抵消,而不是结束它一定量的前后实际完成导航时间? – 2010-11-07 19:13:23
呃,没有。没有什么可以结束的。只需导航到别处。 – 2010-11-07 19:16:08
所以当计时器打勾时,我会在其他地方导航? – MonsterMMORPG 2010-11-07 19:43:55