开发者

WebBrowser Control blocking ajax

I'm using webbrowser control embeded in a winform in my C# app to do some scraping. The content I'm looking for is dynamically loaded with ajax. However, when I navigate to the page the content won't load unless I have no o开发者_开发百科ther code running. I tried doing

while(webbrowser1.isBusy);

But that's not helping. I also tried pausing the program for a few second to give it time to load

Thread.Sleep(2000);

but it's still not loading. If I navigate to the page with no code following, it loads fine. I'm not really sure how I could split this into threads. Any help would be appreciated.


while(webbrowser1.isBusy); and Thread.Sleep(2000); would block the main message pump, and ajax requires a message pump for asynchronous callback. I suggest you to start a timer in DocumentComplete to poll the web page regularly until you think the page is complete. Remember to stop the timer in BeforeNavigate2

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜