#include #include #include Func TwinCharly() local $infoarray=_Task_info() $Str="Hello I'm "&$infoarray[0]&@CRLF $Str&="I Executing "&$infoarray[1]&@CRLF $Str&="And my parent Process PID is :"&$infoarray[2] _FileWriteLog(@ScriptDir & "\Charly.log", "Task : "&@AutoItPID&$Str) _Task_SetVar("threadTwinCharly",1) Local $loop = 0 Do _FileWriteLog(@ScriptDir & "\Charly.log", "Task : "&@AutoItPID & " | I'm waiting TwinTango ") Sleep(1000) Until _Task_GetVar("threadTwinTango")<> 1 _FileWriteLog(@ScriptDir & "\Charly.log", "Task : "&@AutoItPID & " | My twin is ready too. I can open fire...") Do If _Task_GetVar("threadTwinCharly") = 0 Then _FileWriteLog(@ScriptDir & "\Tango.log", "Task : "&@AutoItPID & " | My twin has stopped. I must do the same.") return EndIf _FileWriteLog(@ScriptDir & "\Charly.log", "Task : "&@AutoItPID & " | Are we in combat ? ") If Mod($loop,3) = 0 THEN _FileWriteLog(@ScriptDir & "\Charly.log", "Task : "&@AutoItPID & " | Yes! I must tell Tango i'm busy.") _Task_SetVar("isBusy",1) Sleep(5000) _FileWriteLog(@ScriptDir & "\Charly.log", "Task : "&@AutoItPID & " | I've made my thing! I must tell Tango T'm ready to continue.") _Task_SetVar("isBusy",0) Else _FileWriteLog(@ScriptDir & "\Charly.log", "Task : "&@AutoItPID & " | No, I'm fine. ") Sleep(2000) EndIf $loop = $loop + 1 Until $loop < 50 _FileWriteLog(@ScriptDir & "\Charly.log", "Task : "&@AutoItPID & " | Charly is dead before Tango arrives. Over.") _Task_SetVar("threadTwinCharly",0) EndFunc func TwinTango() local $infoarray=_Task_info() $Str="Hello I'm "&$infoarray[0]&@CRLF $Str&="I Executing "&$infoarray[1]&@CRLF $Str&="And my parent Process PID is :"&$infoarray[2] _FileWriteLog(@ScriptDir & "\Tango.log", "Task : "&@AutoItPID&$Str) Local $loop = 0 _Task_SetVar("threadTwinTango",1) Do _FileWriteLog(@ScriptDir & "\Tango.log", "Task : "&@AutoItPID & " | I'm waiting TwinCharly") Sleep(1000) Until _Task_GetVar("threadTwinCharly") <> 1 _FileWriteLog(@ScriptDir & "\Tango.log", "Task : "&@AutoItPID & " | My twin is ready too. I can open fire...") Do If _Task_GetVar("threadTwinCharly") = 0 Then _FileWriteLog(@ScriptDir & "\Tango.log", "Task : "&@AutoItPID & " | My twin has stopped. I must do the same.") return EndIf If _Task_GetVar("isBusy") = 1 THEN Do _FileWriteLog(@ScriptDir & "\Tango.log", "Task : "&@AutoItPID & " | Charly is busy. I have to wait him") Sleep(3000) Until _Task_GetVar("isBusy") <> 1 _FileWriteLog(@ScriptDir & "\Tango.log", "Task : "&@AutoItPID & " | Charly is done. I can continue.") EndIf _FileWriteLog(@ScriptDir & "\Tango.log", "Task : "&@AutoItPID & " | I'm moving foward while Charly is covering my ass.") Sleep(1000) $loop = $loop + 1 Until $loop < 50 _FileWriteLog(@ScriptDir & "\Charly.log", "Task : "&@AutoItPID & " | Tango has arrived in one piece. Thank you Charly. Over.") _Task_SetVar("threadTwinTango",0) EndFunc Opt("WinWaitDelay",100) ;Global Const @ScriptDir & "\Tango.log" = FileOpen(@ScriptDir & "\Tango.log", 1) ;Global Const @ScriptDir & "\Charly.log" = FileOpen(@ScriptDir & "\Charly.log", 1) _Task_SetVar("threadTwinCharly",0) _Task_SetVar("threadTwinTango",0) _Task_SetVar("isBusy",0) ConsoleWrite("Main Process PID: " & @AutoItPID & " -> Tango and Charly are out. Good luck boys." & @LF) _Task_Create("Charly","TwinCharly") _Task_Create("Tango","Twintango") local $tasks[2]=["Charly","Tango"] _TasK_Join($tasks) ConsoleWrite("Main Process : Thanx and Good Bye" & @LF) ;FileClose(@ScriptDir & "\Tango.log") ;FileClose(@ScriptDir & "\Charly.log")