Multi-Threading Autolt UDF


SUBMITTED BY: Guest

DATE: May 28, 2013, 8:24 a.m.

FORMAT: Text only

SIZE: 1.1 kB

HITS: 1861

  1. $Handle1 = DllCallbackRegister("ThreadTest1", "int", "ptr")
  2. $Handle2 = DllCallbackRegister("ThreadTest2", "int", "ptr")
  3. Func CreateThread($Handle, $struct)
  4. $return = DllCall("kernel32.dll", "hwnd", "CreateThread", "ptr", 0, "dword", 0, "long", DllCallbackGetPtr($Handle), "ptr", DllStructGetPtr($struct), "long", 0, "int*", 0)
  5. Return $return[0]
  6. EndFunc ;==>CreateThread
  7. $Struct1 = DllStructCreate("Char[200];int")
  8. DllStructSetData($Struct1, 1, 10)
  9. CreateThread($Handle1, $Struct1)
  10. $Struct2 = DllStructCreate("Char[200];int")
  11. DllStructSetData($Struct2, 1, 10)
  12. CreateThread($Handle2, $Struct2)
  13. While 1
  14. Sleep(10)
  15. WEnd
  16. Func ThreadTest1($x)
  17. $y = DllStructCreate("char[200];int", $x)
  18. $i = 0
  19. While 1
  20. MsgBox(0, $i, "Thread #1")
  21. $i += 1
  22. WEnd
  23. EndFunc ;==>ThreadTest1
  24. Func ThreadTest2($x)
  25. $y = DllStructCreate("char[200];int", $x)
  26. $i = 0
  27. While 1
  28. MsgBox(0, $i, "Thread #2")
  29. $i += 1
  30. WEnd
  31. EndFunc ;==>ThreadTest2

comments powered by Disqus