Jump to content

Code executes separate loops at the same time


 Share

Recommended Posts

I've seen some weird behavior in my code (I log almost everything).


 

   While 1
      $WaitingTime = TimerDiff($wtTimer)
      sleep(300)
      $Data = TCPRecv($MainSocket, $MaxLength)
      _FileWriteLog($LogFolder&"info.log", "Wait for answer that Server is ready for step 21")
              

            If $Data = "ByeBye" Then
                                       _FileWriteLog($LogFolder&"info.log", "Server tells me to shutdown")
                                       Terminate()

                 ElseIf $Data = "Step 20 Finished on Server" Then
                                        _FileWriteLog($LogFolder&"info.log", "Server answers it is ready for step 21")
                                        ExitLoop


               ElseIf $WaitingTime>4000 Then
                                         _FileWriteLog($LogFolder&"info.log", "No Answer, we still continue" &$Data)
                                         ExitLoop
            EndIf




   WEnd
   _FileWriteLog($LogFolder&"info.log", "Left the WhileLoop")

 

 

And my logs show this:

 


2016-10-24 00:52:39 : Wait for answer that Server is ready for step 21


2016-10-24 00:52:39 : (Logline from completely different loop)

2016-10-24 00:52:39 : (Logline from completely different loop)

2016-10-24 00:52:39 : (Logline from completely different loop)

2016-10-24 00:52:39 : (Logline from completely different loop)

2016-10-24 00:52:40 : Wait for answer that Server is ready for step 21
2016-10-24 00:52:40 : Server answers it is ready for step 21

 

How can this happen? (If there was a "Left the Whileloop" log in between I could imagine it could happen... but now?

I thought AutoIT was singlethreaded...

 

 

 

 

 

Link to comment
Share on other sites

  • Moderators

JohnNash,

AutoIt is single-threaded.

Do you have some form of _Timer_* or Adlib function running elsewhere in the script? That would allow the loop to be interrupted while still running.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

On 10/25/2016 at 9:51 AM, Melba23 said:

JohnNash,

AutoIt is single-threaded.

Do you have some form of _Timer_* or Adlib function running elsewhere in the script? That would allow the loop to be interrupted while still running.

M23

Yes it seems indeed it has something to do with self-made sleep cycles (while ... wend). Also I ran multiple instances of the client by accident.

Link to comment
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
 Share

×
×
  • Create New...