Waiting For Sub

MotoMusher

Active Member
Licensed User
Longtime User
What's the proper way to wait for a process to complete?

In my main activity, I call class1 setupvariables which returns only a boolean value

In class1 setupvariables I call an httpjob (via httputils2service) which needs to complete in jobdone before returning the setupvariables boolean to the main activity

setupvariables is processing and returning false every time, because it finishes before the jobdone.

I set a "WaitingForJob" boolean as true in setupvariables before the httpjob is called
I set "WaitingForJob" to false in the jobdone.

What is the best way for setupvariables to not return a value until waitingforjob = false?

I set timers, but the code does not wait for them. Do Until waitingforjob = false seems inefficient as it could take a while and causes the app to crash.

Thanks. This forum has been fantastic!
 

mc73

Well-Known Member
Licensed User
Longtime User
I set timers, but the code does not wait for them.
I think you should put the remainder of your sub (the one that calls httputils), in a different sub which can be called from inside the timer, once we get jobDone.
 
Upvote 0

MotoMusher

Active Member
Licensed User
Longtime User
Thanks. I needed to step away from it I guess. That's a complete logic failure on my part.

class1 setupvariables should not be a boolean return, just a sub.

when it returns to main, main should check class1.waitingforjob, if it is true, set a timer, then recheck.

I appreciate the help.
 
Upvote 0
Top