General Question: Thread, No Timers Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
lmstearn
Posts: 698
Joined: 11 Aug 2016, 02:32
Contact:

General Question: Thread, No Timers

04 Nov 2016, 07:03

Hi there,
The help file discusses the use of Thread, No Timers in the top part of a script (Autoexec section)
Wish to use it within a Label thus:

Code: Select all

Body
...
Label:
Thread, No Timers
...
X
...
Thread, No Timers, False
Return
...
More Body
Any current timers will not run during the execution of the Label, but code within the Label spawns a new timer X. Will X be suspended once Return is reached or will X run immediately?
Thanks.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
Shadowpheonix
Posts: 1259
Joined: 16 Apr 2015, 09:41

Re: General Question: Thread, No Timers  Topic is solved

04 Nov 2016, 09:33

This is easy enough to test. Here's some quick code I created to do so...

Code: Select all

SetTimer, Test1, 1000
Return

f12::
Thread, NoTimers
Sleep 4000    ; Gives you time to confirm the original timer has stopped triggering.
SetTimer, Test2, -1
Sleep 4000   ; Gives you time to confirm the new timer did NOT trigger.
Thread, NoTimers, False
Sleep 4000    ; Gives you time to confirm the new timer has triggered, and the original has also resumed.
Return

Test1:
ToolTip Timer 1 activated at %A_TickCount%
Sleep 500
ToolTip
Return

Test2:
ToolTip This is timer 2!
Sleep 500
ToolTip
Return
And to answer your question, the timer from X will wait until the Thread, NoTimers, False line has completed.
User avatar
lmstearn
Posts: 698
Joined: 11 Aug 2016, 02:32
Contact:

Re: General Question: Thread, No Timers

04 Nov 2016, 22:01

@Shadowpheonix: Thanks for setting up the test (simple for some is not simple for others). :problem:
It's interesting to note that if instead the line is commented out

Code: Select all

;Thread, NoTimers, False
Some kind of high water mark T is reached and the timers actually commence after a longer wait period.
From the Help consider this statement:
By contrast, if the auto-execute section turns on NoTimers but never turns it off, every newly launched thread (such as a hotkey, custom menu item, or timer) starts off immune to interruptions by timers.
But from what is tested can we also say?
By contrast, if a section other than the auto-execute section turns on NoTimers but never turns it off, every newly launched thread from that section on (such as a hotkey, custom menu item or timer -impossible as it is not launched until T) starts off immune to interruptions by timers.
:arrow: itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Marium0505, mcl and 343 guests