Wait for an event result within a sub

Cableguy

Expert
Licensed User
Longtime User
Hi guys...
is it possible to wait for an event result within a sub???
Ie:
Ussing a webbrowser object, call the navigate method, and wait for it to raise the navigated event in order to retrieve some info...
I know that i can do it with cascating subs....sub is it possible to without leaving the same sub?
 

agraham

Expert
Licensed User
Longtime User
call the navigate method, and wait for it to raise the navigated event in order
If you need to do this then your program structure is probably not optimal. The problem is that the event sub needs to run on the main thread and your call to the navigate method is also on this thread so you need to exit your sub so that the message loop can run to process the event code.

I know that i can do it with cascating subs....
For the reason given above I don't think you can!

You can do it with a loop around DoEvents but it is a bit inelegant and burns processor cycles, but on a desktop it probably doesn't matter.
B4X:
Flag = false
Web.Navigate(somewhere)
Do While Flag = false
  DoEvents
Loop
...


Sub Web_Navigated
  DoStuff
  Flag = true
End Sub
 

Cableguy

Expert
Licensed User
Longtime User
Thanks andrew...
I need to re-think all the aproach....
DllToDate relies on a lot of navigated events, so I'm already using flags, but it will be a bit more easyer now that I know HOW to DOWNLOAD a file from the restricted area...;)
 

taximania

Well-Known Member
Licensed User
Longtime User
Agraham sorted my head out in this thread in a previous app of mine.

http://www.b4x.com/forum/questions-help-needed/847-deal-no-deal.html

Can't you start a timer and check in the tick event to see if you get a response from the webbrowser thingy ?
When you get a response, kill the timer.


But I'm probably wrong again.

And you beat my post :)
 
Last edited:
Top