[2005] Pause future executions without pausing current executions
Hi.
Basically, I have a large set of loops with various tests on database elements and, after all the testing the app either opens a browser and does some stuff, or loops round again with a few different values.
I've been trying to get it to fill in forms, but I keep getting an error:
Object reference not set to an instance of an object.
Now, I'm assuming this error is because it's trying to execute an instruction on something that isn't finished loading yet.
I know I have to use DocumentCompletedEventArgs, and that will tell me when the browser is loaded, but I don't want the rest of the code to continue executing while the browser loads, because it will immediately jump repeat the loops, and I don't want it to just yet.
I tried using a public boolean that was set to true when the documentcompleted, then made a loop after the .navigate instructions to loop until loaded=true, then execute the form instructions, but the loop was clearly infinite and ended up sucking up all the resources so the page never finished loading anyway.
I tried a timer, but without a loop checking for the tick, it was useless and ended up doing the same thing as the above loop.
I've also tried the sleep function within the windows API, but that puts the whole program to sleep and seemed to be of no use to me.
Here's a basic outline of what I want done, so you can visualise it better:
Code:
While test1
'some code here and tests here
While test2
'some more code and tests here too
While test3
Web.Navigate("site")
Web.visible = True
'Need the code to pause in here until the page finishes loading
'Form submission script here
End While
End While
End While
As shown within the code (very very basic representation, for demonstration only really..) I need the code to pause mid-loop somehow while the page loads.
I'm completely lost and stuck, and getting a real headache over this. It needs to be done a LOT within this app, as it's really mainly based on the webbrowser control..
Any help is MUCH appreciated!
Re: [2005] Pause future executions without pausing current executions
Anyone? Even if it's not a direct solution to my problem, if there's an alternate method to do this, I'll consider it!