如何等到WPF浏览器完成加载网页 [英] how to Wait till WPF browser has completed loading webpage

查看:177
本文介绍了如何等到WPF浏览器完成加载网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的WPF浏览器有问题。我想加载一个网页。等待它完全加载,然后输入几个搜索输入,然后检索结果并将其放入excel中。



我无法这样做,主程序加载并完成加载

I have a problem with WPF browser. i want to load a web page. Wait for it load completely and then put few search inputs and then retrieve the result and put it in excel.

I am unable to do so, main program loads and completes the execution before the

pagecomplete_event 

之前的执行。场景是:



加载组件提供商网站

转到搜索选项并搜索我正在阅读的部件号EXCEL文件

将部件号放入搜索栏并单击搜索

下载详细信息

重复多个部分的步骤

我用WinForms完成了这项工作,效果很好。问题是呼唤DOEVENTS。它有时会使我的程序挂起,特别是如果在一个大的列表上运行。所以想在WPF中这样做。



我已经把Load_Complete事件,但正如我所提到的,它是在主程序完成后的那个事件。 />


我搜索并获得此链接:如何在后台线程中创建和使用WebBrowser。但它似乎没有帮助 - 似乎没有WPF中的System.Windows.Deployment - 我得到红色波浪形下划线。我找不到任何其他解决方案似乎也有帮助。

is loaded. The scenario is:

load a component provider website
go to the search option and search for the part number which I am reading for a EXCEL file
put the part number in the search bar and click search
download the details
repeat the steps for MANY parts
I have done this with WinForms, and it works well. The problem is calling DOEVENTS. It sometimes makes my program hang, especially if operating on a big list. So wanted to do it in WPF.

I have put the Load_Complete event, but as I mentioned, it comes to that event after the main program has finished.

I searched and got this link: How to create and use WebBrowser in background thread. But it doesn''t seem to help - there seems to be no System.Windows.Deployment in WPF - I get red squiggly underline. No other solutions that I have found seem to help, either.

推荐答案

如果它在WinForms中运行良好但挂在一个大清单上,WPF无法提供帮助。你会遇到同样的问题。问题是您在UI线程上执行了太多工作。当您的搜索显示时,您需要在后台线程上执行此操作。阅读 System.ComponentModel.BackgroundWorker 类。这是一种引入线程的简单方法。
If it works well in WinForms but hangs on a big list, WPF is not going to help. You will have the same problem. The problem is that you are performing too much work on the UI thread. As your search revealed, you need to do that on a background thread. Read up on the System.ComponentModel.BackgroundWorker class. It is an easy way to get introduced to threading.


这篇关于如何等到WPF浏览器完成加载网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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