Mal eine blödes Beispiel
Code: Alles auswählen
Structure udtThreadData
id.i
exit.i
cmd.i
state.i
; Data
wait.i
value.i
EndStructure
Global.udtThreadData thData1, thData2
Procedure thWork(*data.udtThreadData)
With *data
Repeat
Delay(\wait)
\value + 1
Until \exit
EndWith
EndProcedure
Debug "Start Threads..."
thData1\wait = 100
thData1\id = CreateThread(@thWork(), thData1)
thData2\wait = 200
thData2\id = CreateThread(@thWork(), thData2)
Delay(5001)
Debug "Exit Threads..."
thData1\exit = #True
If WaitThread(thData1\id, 1000) = 0
KillThread(thData1\id)
EndIf
thData2\exit = #True
If WaitThread(thData2\id, 1000) = 0
KillThread(thData2\id)
EndIf
Debug "Thread 1: v= " + thData1\value
Debug "Thread 2: v= " + thData2\value
Um aus Threads Gadgets zu bearbeiten habe ich noch dieses Module
Link: ThreadToGUI