B4J Tutorial [B4X] Resumable Subs - Sleep / Wait For

Discussion in 'B4J Tutorials' started by Erel, Apr 19, 2017.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread in the questions forum.
     
  2. Dave O

    Dave O Active Member Licensed User

    How does a resumable sub using Sleep interact with the activity pausing and resuming?

    For example, I'm working on a poker app that uses sleep(250) to pause between each player's bet. Works great while the app is running.

    However, if I switch out of my app while it's stepping through the players, then return to the app, the sub doesn't appear to resume.

    (If I was using the old method of timers, I would pause/resume the timer when my app was paused/resumed.)

    Thanks!
     
  3. LucaMs

    LucaMs Expert Licensed User

    Interesting question (although, as always, it should have been done in a new thread, now I realize this is useful).

    Obviously, nobody forbids you to use timers again in situations like these, but, waiting for an Erel's answer, it would be useful to perform some tests: where does the code continue after... [read the question above]?

    P.S. I think it will be from a line - unfortunately random - of the code at a higher level than the resumable routine.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
  5. LucaMs

    LucaMs Expert Licensed User

    Given that for the moment a new thread has not been opened, I add only this post, about this topic, because I did a little test, I created a loop with "Sleep" inside, paused the app, resumed it and the loop continued in background.
     
    Last edited: Jan 24, 2018
  6. Dave O

    Dave O Active Member Licensed User

    New thread about Sleep vs. Pause/Resume is here.
     
  7. wle1036

    wle1036 New Member

    wait for have time out ?

    for example if after 5 second don't receive anything then exit waitfor
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    There is no timeout. However nothing bad happens if a sub is waiting for an event that is never raised.

    You can implement a timeout feature in your code. Start a new thread for further discussion.
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice