Opened 11 years ago
Closed 6 years ago
#2979 closed Bug (Works For Me)
AdlibUnregister failing to release timer
| Reported by: | czardas | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.3.12.0 | Severity: | None |
| Keywords: | AdlibUnregister Timer | Cc: |
Description
After AdlibUnregister, the original time interval is retained in memory instead of it being released. This causes a problem when you register the same function again. There should always be approximately 10 seconds between each return and new call to the function in the example below, however it goes wildly out of sync after the first run.
Global $iTimer = TimerInit(), $iSleep = 10000
AdlibRegister("AdlibTimer", $iSleep)
While 1
Sleep(20)
WEnd
Func AdlibTimer()
ConsoleWrite(TimerDiff($iTimer) & @LF) ; Time since the last visit.
AdlibUnRegister("AdlibTimer") ; This should clear everything.
Sleep($iSleep/2) ; Waste a bit of time.
AdlibRegister("AdlibTimer", $iSleep) ; The timer was not reset.
$iTimer = TimerInit() ; The time AdlibTimer was registered.
EndFunc ==
Actually SmOkE_N discovered this issue - see the following link:
http://www.autoitscript.com/forum/topic/167126-adlibregister-issue/?p=1222290
Attachments (0)
Change History (2)
comment:1 by , 11 years ago
comment:2 by , 6 years ago
| Resolution: | → Works For Me |
|---|---|
| Status: | new → closed |
Hi,
Checking with the last release works for me

Reposting the code because I hit the wrong button before.
Global $iTimer = TimerInit(), $iSleep = 10000 AdlibRegister("AdlibTimer", $iSleep) While 1 Sleep(20) WEnd Func AdlibTimer() ConsoleWrite(TimerDiff($iTimer) & @LF) ; Time since the last visit. AdlibUnRegister("AdlibTimer") ; This should clear everything. Sleep($iSleep/2) ; Waste a bit of time. AdlibRegister("AdlibTimer", $iSleep) ; The timer was not reset. $iTimer = TimerInit() ; The time AdlibTimer was registered. EndFunc