Guest Posted July 17, 2015 Share Posted July 17, 2015 (edited) Code:expandcollapse popupHotKeySet('{ESC}','Exit1') Func Exit1() Exit EndFunc $Inuse = 0 AdlibRegister('Test1',1000) AdlibRegister('Test2',1000) Func Test1() If $Inuse Then Return $Inuse = 1 ConsoleWrite('Test1_1' & @CRLF) ConsoleWrite('Test1_2' & @CRLF) ConsoleWrite('Test1_3' & @CRLF) ConsoleWrite('Test1_4' & @CRLF) ConsoleWrite('Test1_5' & @CRLF) ConsoleWrite('Test1_6' & @CRLF) ConsoleWrite(@CRLF & @CRLF) $Inuse = 0 EndFunc Func Test2() If $Inuse Then Return $Inuse = 1 ConsoleWrite('Test2_1' & @CRLF) ConsoleWrite('Test2_2' & @CRLF) ConsoleWrite('Test2_3' & @CRLF) ConsoleWrite('Test2_4' & @CRLF) ConsoleWrite('Test2_5' & @CRLF) ConsoleWrite('Test2_6' & @CRLF) ConsoleWrite(@CRLF & @CRLF) $Inuse = 0 EndFunc While 1 Sleep(100) WEndIs it possible that in an extreme case it will print something like thisTest1_1 Test2_1 Test1_2 Test2_2 Test1_3 Test2_3 Test1_4 Test2_4 Test1_5 Test2_5 Test1_6 Test2_6In this case what needs to happen for this output is:The CPU performs the two functions about at the same time in this way:Step 1) Execute line "If $Inuse Then Return" in function "Test1" - The result is not returnStep 2) Execute line "If $Inuse Then Return" in function "Test2" - The result is not return (This is bad ...)Step 3) Execute the second line in "Test1"Step 4) Execute the second line in "Test2" And so on.. Is this behavior is possible? Edited July 17, 2015 by Guest Added code tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 17, 2015 Moderators Share Posted July 17, 2015 gil900,What have you done so far to test if this is possible? What checking code have you added to the base code you posted to see what is happening internally?M23P.S. You have been here long enough to know that when you post code you should use Code tags. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Guest Posted July 17, 2015 Share Posted July 17, 2015 (edited) What have you done so far to test if this is possible?I just debugged a crash and according to the bedbug(I mean - Manual Investigation in my code and based on visual output behavior of the app.. If you understand what I mean) I did not found any failure in the code. the failure could happen only if this behavior really occurs. I am using the app very often and this crash happened only once so it fits to this extreme case theory that normally does not happen And I used Code tags.. Check your browser EDIT: This could also happen if there is bug in UBound() function but this is very very unlikely Edited July 17, 2015 by Guest Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 17, 2015 Moderators Share Posted July 17, 2015 gil900,So if you have checked and found no problem, how do expect anyone else to find one? Are we all supposed to run all sorts of tests to try and break the code? Be reasonable.And as far as I know the 2 functions will run consecutively - never as you fear. I used Code tagsThe OP now has code tags because I added them (check the edit remark at the bottom of the post) - you had used quotes.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Guest Posted July 17, 2015 Share Posted July 17, 2015 (edited) So if you have checked and found no problem, how do expect anyone else to find one?I did not expect/ask that someone will run tests for hours or something like that ..I just wanted to know if it is known that such behavior is possible (by a known bug or design choice) and this knowledge will help me somehow especially if there is confirmation to my concern. The OP now has code tags because I added them (check the edit remark at the bottom of the post) - you had used quotes.Ops, ok I didn't so that you edited the OP before Edited July 17, 2015 by Guest Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 17, 2015 Share Posted July 17, 2015 Adlib functions don't run in their own thread, so no, what you describe in the OP simply can't happen. If adlibs can interrupt each other (I don't remember, but simple enough for you to check yourself) it would just beTest1_1 Test2_1 Test2_2 Test2_3 Test2_4 Test2_5 Test2_6 Test1_2 Test1_3 Test1_4 Test1_5 Test1_6 .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Guest Posted July 17, 2015 Share Posted July 17, 2015 I knew that.This is the lesson I learned -This is a dangerous idea to delete elements in Array inside Adlib function while a non-Adlib code may access the array.Even something likeIf $ArrayInUse Then Return $ArrayInUse = 1Does not always prevents disaster. The safe way is not to delete elements while a non-Adlib code may access the array.. Thanks anyway.I know what to do Link to comment Share on other sites More sharing options...
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