Page 1 of 1

Do While Prevents Timer

PostPosted: Thu Jun 14, 2012 6:51 pm
by Slowdown
Some simpel code,
Code: Select all
Event Init()
  Tm1.Interval = 1000
  Tm1.Enabled = True
  Tm1.Stop()
  doDelay = True
  MyDelay = 5
  Tm1.Start()
  Do While doDelay = True
    stdout("nothing " & String(DelaySeconds))
  Loop
  MsgBox("ready waiting")

The Timer Event,
Code: Select all
Signal on_Tm1_Event()
  DelaySeconds = DelaySeconds + 1
stdout(DelaySeconds)
  If DelaySeconds = MyDelay Then
    doDelay = False
  End If
End Signal

The Do While Loop is preventing that the Timer Event is called.
stdout(DelaySeconds) show no output until you disable the Do While Loop.

Re: Do While Prevents Timer

PostPosted: Thu Jun 14, 2012 8:37 pm
by Henning
Add a DoEvents() in the loop, or the loop will not allow other things to run and the Form will freeze.

/Henning

Re: Do While Prevents Timer

PostPosted: Fri Jun 15, 2012 12:22 pm
by Slowdown
Yup already did that but i thought that the Timer Event always was triggered.
How are you doing ?

Re: Do While Prevents Timer

PostPosted: Fri Jun 15, 2012 1:04 pm
by Henning
I have this in Global, Timer1 is set to 1 second.
Code: Select all
Signal on_Timer1_Event()
  If TimeOut > 0 Then
    TimeOut = TimeOut - 1
  End If
'  Timer1.Enabled = False
End Signal


And this in a Module waiting for a UDP packet max 10 seconds.
Code: Select all
    TimeOut = 10
    Do
      If Len(lanBuf) > 17 Then
        Break
      End If
      DoEvents()
    Loop While TimeOut > 0 '** While Timer < TimeOut 'uBaseConn


/Henning

Re: Do While Prevents Timer

PostPosted: Fri Jun 15, 2012 1:42 pm
by Slowdown
:D
I meant are you recovering from 'the one wrong click'
But thanks.

Re: Do While Prevents Timer

PostPosted: Fri Jun 15, 2012 1:58 pm
by Henning
A little weird in my head... :roll:

Recovered no, but I have accepted that speed kills...

/Henning