等待网页导航和刷新

发布于 2024-12-11 21:56:06 字数 784 浏览 0 评论 0原文

我已经为这个项目工作了大约两周时间。我在导航到页面然后刷新页面时遇到问题。问题是它会导航和刷新,但因为它看起来很混乱,我想触发一个“请等待”表单,

webBrowser.Navigate("www.thelineiamnavigatingto");
pleasewait.Show(); //shows the pleasewait form.
while (webBrowser.ReadyState != WebBrowserReadyState.Complete)
{
    Application.DoEvents();
}

webBrowser.Refresh();
while (webBrowser.ReadyState != WebBrowserReadyState.Complete) //program Skips this
{
    Application.DoEvents(); 
}
pleasewait.Hide(); //Hides the pleasewait because the page is now ready

我无法真正解释为什么我需要再次刷新。我已经考虑过不刷新页面,所以我必须这样做。有没有办法重置“WebBrowserReadyState”我相信发生的事情是浏览器加载,然后它声明“WebBrowserReadyState”无论如何都可以将其重置回未完成/等待? - 我希望是这样,因为如果事实是这段代码不寻找页面刷新,那么我不知道下一步该做什么。因此,当我刷新页面并将相同的“While”循环放在第一个循环下方时 - 它会跳过它吗?

有专家知道更好的方法吗?或者修复我的代码?我将不胜感激。 非常感谢您的浏览。

I have been working on this one program for around 2 weeks now. I am having an issue with navigating to a page then refreshing the page. The issue is it will navigate and refresh but because it looks messy I want to trigger a "please wait" form

webBrowser.Navigate("www.thelineiamnavigatingto");
pleasewait.Show(); //shows the pleasewait form.
while (webBrowser.ReadyState != WebBrowserReadyState.Complete)
{
    Application.DoEvents();
}

webBrowser.Refresh();
while (webBrowser.ReadyState != WebBrowserReadyState.Complete) //program Skips this
{
    Application.DoEvents(); 
}
pleasewait.Hide(); //Hides the pleasewait because the page is now ready

I can't really explain why I need to refresh again. I have looked into not refreshing the page so I have to do this. Is there a way to reset the "WebBrowserReadyState" I beleive whats happening is the browser loads and it then states that "WebBrowserReadyState" is there anyway to reset this back to notcomplete/waiting? - I am hopeing it's that because if it's the fact that this bit of code doesnt look for a page refreshing then I am not sure what to do next. So when I refresh the page and place same "While" loop below the first one - It skips it?

Does any specialist know of a better way to do this? or a fix for my code? I would be very greatful.
Many thanks for looking.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风流物 2024-12-18 21:56:06

我认为浏览器保持其就绪状态是因为对于相同的 URL 来说刷新过程太快(甚至是立即)。

我认为你没有关注你的主要问题。您不需要在第一次加载页面后立即刷新页面。如果您需要网络应用程序有问题,那么现在您有两个问题。我建议尝试寻找另一种解决方案。

祝你好运 :)

I suppose the browser keeps its ready state because the refresh process is just too fast (or even immediate) for the same URL.

I think you aren't focusing on your main problem. You should not need to immediately refresh a page just after loading it for the first time. If you need that there is a problem with you web application, and now you have two problems. I would suggest trying to find another solution.

Good luck :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文