Sign in to follow this  
Followers 0
imNew

quick question about sleep

8 posts in this topic

2 question:

1 if sleep(1000) is called in the middle of sleep(10000) @ the 5 th second what will happen?

total sleep of (6000)

or total sleep of (11000)?

2 sleep() can not prevent interrupt being fired and handled. thus in my "Pause()" func, I need to disable all the hotkeys except for the hotkey for "Resume()' right?

Share this post


Link to post
Share on other sites



Sleep applies to each thread realistically. AutoIt does not support real multithreading. It will run two pieces of code alternating I guess, but not at the same time.

You could always try the double sleeps. It should cause no harm.

Share this post


Link to post
Share on other sites

thanks for replying but I don't think I understood

let me rephrase:

1) if sleep(1000) is called in the middle of sleep(10000) @ the 5 th second what will happen?

total pause time of 6 secs? (the sleep(1000) has terminated sleep(10000))

total pause time of 11 secs? (the sleep(1000) paused the execution of sleep(10000))

2) sleep() can not prevent interrupt being fired and handled. thus in my "Pause()" func, I need to disable all the hotkeys except for the hotkey for "Resume()' right?

Share this post


Link to post
Share on other sites

1) if sleep(1000) is called in the middle of sleep(10000)

can't be done

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

ok, let me provide some context:

while 1; GUI while

sleep(1000)

wend

key pressed and interrupt routine is called

func Interrupt_handling_routine_being_called()

sleep(100)

;do stuff

endfunc

so it's possible that sleep(100) is called in the middle of that sleep(1000) right?

Share this post


Link to post
Share on other sites

You are 80% there....

just finish that script above with a timer and see

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Hmmm.... this is kinda wierd... Anyways, I wrote a timer script you can play around with to test some theories with the Sleep function.

HotKeySet("{Ins}", "Interrupt")
AdlibEnable("TimeCalc", 5)
$Timer = TimerInit()

Sleep(10000)

Func Interrupt()
    Sleep(5000)
EndFunc

Func TimeCalc()
    $Diff = Round(TimerDiff($Timer)/1000, 2)
    TrayTip("Time", $Diff, 5)
EndFunc

Feel free to play around with it, and see what results you can come up with.


- Dan [Website]

Share this post


Link to post
Share on other sites

WOW, thanks a lot, the code definitely helped, that AdlibEnable function, which I never knew existed is a MAJOR helper=), I was going to ask how to handle exceptions, but that adlibenable opens up so many options

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0