Question about looping

dnhype

New member
Joined
Sep 24, 2010
Messages
4
Programming Experience
Beginner
Hi there,

Im novice to vb.net learning from my self over time..

Im working on a project that have to work in loop / or repetitive task.

Let says i need to login on a website using a Webbrowser.

i create in a Module1 a Public function Login()

set this function as false

Perform the login

Return true.


Now the way i call this function is into an other Sub let's call It
Public sub hello()

hello sub is a loop, doing task until textbox reach X value.

In the loop i call the Login function this way ->

do
loop until Login() = true

So my Sub wait for the function login return True.


Is this a good way ?
Cause after time it seem to crash i cant figure why.
First hours the program works OK, however momery footprint increase till my apps crash.


My code is predy long so i didn't past it here if you guys need let me know.
I just want to know a few things

-Is the way i loop is good ?
-In a loop, can i call other function/sub without breaking the loop cycle.
 
What you're talking about is called "busy waiting" and it's something you should always avoid if at all possible. In your case, you should start the login process and then end the method there. The WebBrowser will then raise its DocumentCompleted event when the next page loads and you can determine whether the login was successful or not in the event handler.
 
Back
Top