المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Do loop while waiting for a component event



C++ Programming
04-17-2009, 10:31 PM
Hello everyone. I come from a Delphi background to VC++ 2008. I have searched the board and articles for my "problem" but to no avail. I hope someone out there can help me with this even tho it may sound like a very dumb question. The entire problem could probably be resolved with a different approach but this is what I have so far so feel free to modify/suggest whatever you feel may help.

1. after a button is clicked, a do ... while loop is started
2. in the middle of the loop, webBrowser is "told" to do a webBrowser->Navigate
3. an url keeping variable is updated by incrementing one of the integers needed to get the right url
4. integer variable is incremented
5. loop keeps going up and webBrowser navigates again (this time to a different address) until the integer variable = user specified number

This loop can, based on user input, be executed 10+ times or so, basically telling the webbrowser to navigate to 10 different urls.

The problem is - the loop will prevent the webbrowser to fully finish loading the site and at the end it manages to navigate to 1 url only.

I understand that I need to use the DocumentCompleted event on the webBrowser.

The question is: how do I combine the loop with the event?
Is there backgroundworker or some other component I should use?

I hope I provided enough info for the answer. Feel free to ask for more details/code if needed.