Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

What to do when _Timer_KillTimer() fails?

$
0
0
I have code which uses several timers.  The functions called when these timers go off execute a _Timer_KillTimer for the $timerID passed in.  Most of the time this works just fine.  Occasionally it does not and the offending timer gets stuck in an infinite loop.  Does anyone have any ideas how to fix this?

The script is quite long, but the troublesome parts are something like this:
[ autoit ]      
; create a bunch of timers For $i = 1 to 50 step 1     _Timer_SetTimer(0, 100 * $i, "MyTimerFunction") Next ; respond appropriately, then kill timer. Func MyTimerFunction($a, $b, $timerID, $c)     If _Timer_KillTimer(0, $timerID) Then          ConsoleWrite($timerID & " was killed. " & @CRLF)     else          ConsoleWrite($timerID & " could not be killed. " & @CRLF)     EndIf EndFunc

Usually $timerID is killed just fine.  However, when it is not it seems to be impossible to kill no matter how many times I re-call _Timer_KillTimer or  _Timer_KillAllTimers.  Also, it will continue to call MyTimerFunction() endlessly until the script is terminated.

Any ideas why the kill function is failing or how to make it work?  It seems to happen more often when the interval between timers is short.

Thank you for reading.

Viewing all articles
Browse latest Browse all 12506

Trending Articles