Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 0.81 KB | None | 0 0
  1. #cs
  2.   Registering these threads will halt the event / loop that's already running resulting in partial-multithreading functionality
  3.   Note that this slows down your program to an extent, but not substancially.
  4. #ce
  5.  
  6. Simulation() ; start the simulation
  7.  
  8. Func Simulation()
  9.     $dummy_boolean = False
  10.     ThreadRegister()
  11.     Do ; Make a deliberate infinite-loop
  12.         MsgBox(0, "", "test")
  13.     Until $dummy_boolean = True
  14. EndFunc
  15.  
  16. Func ThreadRegister() ; Register the threads
  17.     AdlibRegister("Thread1", 100)
  18.     AdlibRegister("Thread2", 100)
  19.     AdlibRegister("Thread3", 100)
  20. EndFunc
  21.  
  22. Func Thread1()
  23.     $nMsg = GUIGetMsg()
  24.     If $nMsg = $EVENT Then
  25.         ; Do stuff
  26.     EndIf
  27. EndFunc
  28.  
  29. Func Thread2()
  30.     $nMsg = GUIGetMsg()
  31.     If $nMsg = $EVENT Then
  32.         ; Do stuff
  33.     EndIf
  34. EndFunc
  35.  
  36. Func Thread3()
  37.     $nMsg = GUIGetMsg()
  38.     If $nMsg = $EVENT Then
  39.         ; Do stuff
  40.     EndIf
  41. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement