C# 问题 WebBrowserReadyState - 了解页面何时刷新
我希望这不是一个愚蠢的问题。不过,我目前正在编写一个程序,它是网站预订系统的前端。 当我导航到特定链接时,它会记住页面上以前的信息 - 所以我必须让它加载页面然后刷新 - 这样做有点混乱,所以我创建了另一个在加载过程中出现的名为 pleasew 的表单。 CS。第一个 while 循环将显示“pleasew”,然后我假设“WebBrowserReadyState”设置为“Complete”。然后它或多或少会在完成刷新之前关闭“pleasew”表单。我可以做些什么来在刷新之前重置“WebBrowserReadyState”吗?或者还有其他解决方案吗?
非常感谢您的查看
这是代码:
private void button7_Click_1(object sender, EventArgs e)
{
webBrowser1.Navigate("www.test.co.uk");
pleasew pleasewait = new pleasew();
pleasewait.Show();
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
webBrowser1.Refresh();
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
pleasewait.Hide();
}
I hope this isn't a stupid question. However I am writing a program at the moment which is a front end for a website booking system.
When I navigate to a specific link it remembers previous information on the page - So I have to make it load the page and then refresh - It's a bit messy doing this, so I have created another form which comes up during the loading called pleasew.cs. It will show "pleasew" for the first while loop and then I am assuming that "WebBrowserReadyState" is set to "Complete." and it more or less then closes the "pleasew" form before it's completed the refresh. Is there anything I can do to reset "WebBrowserReadyState" before it refreshes? Or is there another solution at all?
Many Thanks for looking
Here is the code:
private void button7_Click_1(object sender, EventArgs e)
{
webBrowser1.Navigate("www.test.co.uk");
pleasew pleasewait = new pleasew();
pleasewait.Show();
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
webBrowser1.Refresh();
while (webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
pleasewait.Hide();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解您的问题,您相信刷新时就绪状态不会脱离完整状态。您是否进行过调试以确保它永远不会进入第二个 while 循环?也许因为它是刷新,所以它从缓存加载,这就是您困惑的根源。
尝试执行第二次导航而不是刷新,看看会发生什么。
If I understand your problem right, you beleive the readystate doesn't get out of complete status when you do your refresh. Have you debugged to be certain it never enters the second while loop? Maybe because it's a refresh, it loads up from the cache, and that's the source of your confusion.
Try doing a second Navigate instead of Refresh and see what happens.