-
Notifications
You must be signed in to change notification settings - Fork 5
/
example.au3
41 lines (34 loc) · 1.01 KB
/
example.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include 'authread.au3'
_AuThread_Startup()
$hThread = _AuThread_StartThread("sendalert")
Func sendalert()
While 1
$msg = _AuThread_GetMessage()
If $msg Then
MsgBox(0, "Alert from thread", $msg)
EndIf
; randomly sends (or not) messages to the main thread
$rand = Random(1, 10, 1)
If $rand = 2 Then
_AuThread_SendMessage(_AuThread_MainThread(), "Hey!")
EndIf
WEnd
EndFunc
; main thread
While True
; randomly sends (or not) messages to the main thread
$rand = Random(1, 3, 1)
TrayTip("Main thread window", "Sorted number: " & $rand, 1)
If $rand = 2 Then
_AuThread_SendMessage($hThread, $rand & " was sorted")
EndIf
; get some message sent to the main PID
$msg = _AuThread_GetMessage()
If $msg Then
MsgBox(0, "Wayback message", "The thread sent: " & $msg)
EndIf
Sleep(1000)
WEnd
; The line below is just an example,
; as once the main thread is closed or killed, the UDF will automatically close all the started threads
_AuThread_CloseThread($hThread)