C#制作程序等待,直到布劳尔完成加载网页 [英] C# Making program wait untill brower finish loading webpage

查看:247
本文介绍了C#制作程序等待,直到布劳尔完成加载网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

如何让我的计划要等到网页加载完成执行下一statement.I尝试过程:: WaitForInputIdle()之前;但它不等待。任何人有任何idea.thanks

 的ProcessStartInfo PINFO =新的ProcessStartInfo(firefox.exe);

            pInfo.Arguments =htt​​p://xxx.com;

            进程p =的Process.Start(PINFO);

            p.WaitForInputIdle();


            pInfo.Arguments =htt​​p://yyy.com;

             P =的Process.Start(PINFO);

             p.WaitForInputIdle();
 

解决方案

您不能。这里的问题是,Firefox不传达回来的时候网页加载。您将如看到的问题时,Firefox的希望才打开网页,进行自我更新。这是怎么回事时,页面加载沟通回​​来?在这两者之间,整个firefox.exe可执行文件已被替换,并通过连接你的进程已久违。

WaitForInputIdle 做了非常具体的工作,这是不是你所期望的。视窗工程通过消息泵。当你如将鼠标移动到一个窗口,一个消息被发送到该窗口。 WaitForIdleInput 返回时,该应用程序已处理,已收到的第一条消息,因此当Windows知道它是'敏感'。

HI ,

How do i make my program to wait until webpage finish loading before executing next statement.I tried Process::WaitForInputIdle(); but it doesnt wait . Any one has any idea.thanks

ProcessStartInfo pInfo = new ProcessStartInfo("firefox.exe");

            pInfo.Arguments = "http://xxx.com";

            Process p  = Process.Start(pInfo);

            p.WaitForInputIdle();


            pInfo.Arguments = "http://yyy.com";

             p = Process.Start(pInfo);

             p.WaitForInputIdle();

解决方案

You can't. The problem here is that Firefox does not communicate back when the web page has loaded. You will for example see issues when Firefox wants to update itself before it opens the web page. How is it going to communicate back when the page is loaded? In between, the entire firefox.exe executable has been replaced, and the connection with your Process has been long lost.

The WaitForInputIdle does a very specific job, and this is not what you expect. Windows works through a message pump. When you e.g. move the mouse over a window, a message is send to that window. WaitForIdleInput returns when the application has processed the first message it has received, so when Windows knows it is 'responsive'.

这篇关于C#制作程序等待,直到布劳尔完成加载网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆