views:

41

answers:

1

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 other 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.

A: 

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

Sheng Jiang 蒋晟
yes, this is exactly what I ended up doing.
silverbandit91