Android Question one shot timer

Discussion in 'Android Questions' started by MbedAndroid, Mar 24, 2015.

  1. MbedAndroid

    MbedAndroid Active Member Licensed User

    b4a has a periodic timer, you can enable and disable it.
    You cannot read the current value the moment you disabled it neither you can write a new value, or just only by initing the timer

    I get the idea that when you start/stop/start the timer, it will continue at the last count, so no reset to initial value.
    The only way seems to be to reinit the timer every time it seems, but may be i'm wrong?

    I need that one shot timer to set a timeout when receiving data.
  2. JordiCP

    JordiCP Well-Known Member Licensed User

    Don't know if it is what you are after, but if you need a one-shot timer, you only have to do disable it in its Tick event vand set it again when you need it

    Sub myTimer_Tick
    False 'one shot
      'and perform any action or set some flag...
      flg_timeOut=True 'for instance
    end sub
    and set it again when you want
    Sub Set_Timer
    1000 'whatever
    end sub
  3. MbedAndroid

    MbedAndroid Active Member Licensed User

    thnx, seems i need new glasses, didnt noticed that interval line
  4. RandomCoder

    RandomCoder Well-Known Member Licensed User

    @MbedAndroid I use a slight variation on this in that I can also change the interval time with my sub call...
    ..... ' your other code
        tmr_Reset(2500' reset timer to 2.5s interval

    Sub tmr_Reset(ms As Int)
    End Sub
    DonManfred and JordiCP like this.
  5. MbedAndroid

    MbedAndroid Active Member Licensed User

    yes better in that way to get exactly the time needed
  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