milos83 Posted Thursday at 01:33 AM Posted Thursday at 01:33 AM (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 Thursday at 01:49 AM by milos83
Nine Posted Thursday at 03:17 AM Posted Thursday at 03:17 AM 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. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Multi-Threading Made Easy
lIlIIlIllIIIIlI Posted Thursday at 03:57 AM Posted Thursday at 03:57 AM (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 Thursday at 04:00 AM by lIlIIlIllIIIIlI
argumentum Posted Thursday at 03:58 AM Posted Thursday at 03:58 AM 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.
milos83 Posted 13 hours ago Author Posted 13 hours ago On 2/20/2025 at 4:17 AM, Nine said: 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. On 2/20/2025 at 4:58 AM, argumentum said: ..because, it interrupts the main code to run the AdLib. And you don't give it a chance to do anything else. Ain't that the truth. 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 ? Both of you are missing the point. I am Unregistering AdLib so it doesn't trigger again right after finishing. My assumption was that by unregistering and then re-registering it at the very exit of the function, it will have a 1s delay between function runs. This is not the case. It runs right away. Why is this? From the helpfile : Quote note that the first call to the function is after the specified time period and not immediately the function is registered. This is not true if done from the actual function.
Developers Solution Jos Posted 12 hours ago Developers Solution Posted 12 hours ago It looks like the AdlibUnRegister("CheckWorkers") doesn't get performed until the called interrupt function by AdlibRegister("CheckWorkers", 1000) ends! Since you do the AdlibRegister("CheckWorkers", 1000) again before the Interrupt call ends, it looks like the counter doesn't get reset at all. The example you posted is really some "wrong coding logic" where you want to stop an interrupt happening in the interrupt call itself, which would never happen anyway! I haven't checked the internal code for this, but some tests I did with consolewrite() debug lines seem to prove this. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now