I have a loop that goes through a number of values. With every value iterated, a page is loaded in a webbrowser control (with the value passed as a parameter) and when the page is loaded and read, the loop should go to the next value in the list and continue until all values are processed. I need a way to pause the procedure while the website is loading asynchronously and then resume once the page loading/reading process is complete.
The way I am doing is by using something like this, where "ReadingInProgress" is a global variable:
ReadingInProgress = True
wb.Navigate("http://mywebsite.com/mypage.aspx" & c)
While ReadingInProgress
Application.DoEvents()
End While
The "DocumentCompleted" event of the webrowser control set "ReadingInProgress" to false which causes the while loop to exit and resume the procedure. This works, but I realize that it puts a strain on the CPU. Is there a better, less CPU intensive way to do this?
Thanks!