Page 1 of 1

Does window timer still exist?

Posted: Sun Mar 13, 2016 4:10 pm
by Korolev Michael
I suppose, we need a function kinda "IsWindowTimer", that checks whether timer still alive.
Just like "IsThread"

Oh my god, I found duplicate 2010-year thread.

Re: Does window timer still exist?

Posted: Sun Mar 13, 2016 6:53 pm
by Julian
Threads can be stopped many many ways so IsThread is useful. However a window timer created with AddWindowTimer will run until you cancel it with RemoveWindowTimer (or I assume CloseWindow) so you should be able to track it quite easily?

Re: Does window timer still exist?

Posted: Sun Mar 13, 2016 7:52 pm
by Korolev Michael
track it quite easily
HOW?

When I cancelled timer, how then I can check, is it running or not?

Re: Does window timer still exist?

Posted: Sun Mar 13, 2016 11:31 pm
by Demivec
Korolev Michael wrote:
track it quite easily
HOW?

When I cancelled timer, how then I can check, is it running or not?
Maybe:

Code: Select all

Global NewMap timers()

Procedure _AddWindowTimer(window, timer, timeout)
  timers(Str(window) + "_" + Str(timer)) = timeout ;signal timer present
  AddWindowTimer(window, timer, timeout)
EndProcedure

Procedure _RemoveWindowTimer(window, timer)
  If FindMapElement(timers(), Str(window) + "_" + Str(timer))
    RemoveWindowTimer(window, timer)
    DeleteMapElement(timers())
  EndIf
EndProcedure

Procedure IsWindowTimer(window, timer)
  ProcedureReturn Bool(FindMapElement(timers(), Str(window) + "_" + Str(timer)) <> 0)
EndProcedure

Procedure GetWindowTimerTimeout(window, timer)
  If FindMapElement(timers(), Str(window) + "_" + Str(timer))
    ProcedureReturn timers()  
  Else
    ProcedureReturn 0
  EndIf
EndProcedure

Macro AddWindowTimer(window, timer, timeout)
 _AddWindowTimer(window, timer, timeout)
EndMacro

Macro RemoveWindowTimer(window, timer)
  _RemoveWindowTimer(window, timer)
EndMacro

Macro ChangeWindowTimerTimeout(window, timer, newTimeout)
  _RemoveWindowTimer(window, timer)
  _AddWindowTimer(window, timer, newTimeout)
EndMacro

Re: Does window timer still exist?

Posted: Mon Mar 14, 2016 7:41 am
by Korolev Michael
Thanks, that's good solution.
Didn't think about overloading.