Hi there,
I can't figure how to make my program work using thread, loop and sub..
Ill explain
I make web application to automate work.
Function/Sub i have so far
-Login
-Update Info
-Logout
And this should loop infinite
I want to have a function or sub for my login so i dont have to re-type all code if i need to call it later in other sub/function.
Now my problem
How to make this loop properly
Call login, wait for it to be logged or return true, update info + update UI , Logout, Loop infinite
All this using webbrowser and thread.
i type this code in notepad so it's note the real code but its how it flow.
is this a good way ? i cant make it work im getting mad !
The way i managed to make it work is in Single Thread application, having each sub / function the entire code flow ( login, update info, logout is not 1 sub )
but more function i have they all need a login function so i copy past the long code in every sub which make my apps freaking LONG im getting lost in the code. and if i need to update the login stuff i need to do it everywhere...
please help someone
I can't figure how to make my program work using thread, loop and sub..
Ill explain
I make web application to automate work.
Function/Sub i have so far
-Login
-Update Info
-Logout
And this should loop infinite
I want to have a function or sub for my login so i dont have to re-type all code if i need to call it later in other sub/function.
Now my problem
How to make this loop properly
Call login, wait for it to be logged or return true, update info + update UI , Logout, Loop infinite
All this using webbrowser and thread.
VB.NET:
Public function Login() as boolean
Do stuff....
Verification...
We'r loged then
Login = True
return Login
end function
Public sub UpdateUI(byval Information as string)
form1.textbox1.text = Information
end sub
public function Logout() as boolean
do stuff for logout,,
verification
if logout then
logout = true
return Logout
end function
Sub Mythread()
do
application.doevents
loop until login = true
UpdateUI(someinfo) <-- This update UI so needs some Delegate or Invoke not sure ...
do
do
application.doevents
loop until logout = true
end sub
Then my button to start thread
button1 sub ...
dim thread as new thread
thread = new thread(address of Mythread)
thread.setappartementstate = sta ( for webrowser it need this state )
thread.start
loop until X = Y 'here is the infinite loop
i type this code in notepad so it's note the real code but its how it flow.
is this a good way ? i cant make it work im getting mad !
The way i managed to make it work is in Single Thread application, having each sub / function the entire code flow ( login, update info, logout is not 1 sub )
but more function i have they all need a login function so i copy past the long code in every sub which make my apps freaking LONG im getting lost in the code. and if i need to update the login stuff i need to do it everywhere...
please help someone