Jump to content

Recommended Posts

Posted (edited)

 

Using latest Autoit

The following code never gets to the third line (msgbox).

Why?
 

CheckWorkers()
Sleep(1000)
MsgBox(0,0,0);never gets here


Func CheckWorkers()

    AdlibUnRegister("CheckWorkers")

    Sleep(1000)
    AdlibRegister("CheckWorkers", 1000)

EndFunc

The bottom line is, if the duration of the function is >= Adlib interval, it will run forever. No matter if you did AdlibUnRegister on function start or not.

Edited by milos83
Posted

That is a truly bad written code.  What would be the purpose of creating such a bad logic ?  If you are trolling us to explain why, I suggest you take the time to test you false assumptions.

Posted (edited)

I am guessing if the duration of AdlibRegister("CheckWorkers", 1000) is equal to the first Sleep(1000), it cannot ever reach that Sleep, because you scheduled it to run CheckWorkers.

Edited by lIlIIlIllIIIIlI
Posted
2 hours ago, milos83 said:

The following code never gets to the third line (msgbox). Why ?

Global $iSleep = 500 ; 1000
codeIsAtLineNumber()
CheckWorkers()
codeIsAtLineNumber()
Sleep($iSleep)
codeIsAtLineNumber()
MsgBox(262144, "0", "0", 10) ;never gets here
codeIsAtLineNumber()

Func CheckWorkers()
    codeIsAtLineNumber()
    AdlibUnRegister("CheckWorkers")
    Sleep($iSleep)
    AdlibRegister("CheckWorkers", 1000)
    codeIsAtLineNumber()
EndFunc   ;==>CheckWorkers

Func codeIsAtLineNumber($iScriptLineNumber = @ScriptLineNumber)
    ConsoleWrite("@@(" & $iScriptLineNumber & ") : " & @MIN & ":" & @SEC & "." & @MSEC & @CRLF)
EndFunc   ;==>codeIsAtLineNumber

..because, it interrupts the main code to run the AdLib. And you don't give it a chance to do anything else.

37 minutes ago, Nine said:

That is a truly bad written code.

Ain't that the truth.

2 hours ago, milos83 said:

The bottom line is,...

I don't know what the bottom line is. Looking at parallel processing in the WiKi would be the thing to do if the other function is so ..., time consuming ?

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...