#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($logFileCharly, "Task : "&@AutoItPID,$Str) _Task_SetVar("threadTwinCharly",1) Local $loop = 0 Do _FileWriteLog($logFileCharly, "Task : "&@AutoItPID & " | I'm waiting TwinTango") Sleep(1000) Until _Task_GetVar("threadTwinTango") <> 1 _FileWriteLog($logFileCharly, "Task : "&@AutoItPID & " | My twin is ready too. I can open fire...") Do If _Task_GetVar("threadTwinCharly") 0 Then _FileWriteLog($logFileTango, "Task : "&@AutoItPID & " | My twin has stopped. I must do the same.") return EndIf _FileWriteLog($logFileCharly, "Task : "&@AutoItPID & " | Are we in combat ? ") If Mod($loop,3) = 0 THEN _FileWriteLog($logFileCharly, "Task : "&@AutoItPID & " | Yes! I must tell Tango i'm busy.") _Task_SetVar("isBusy",1) Sleep(5000) _FileWriteLog($logFileCharly, "Task : "&@AutoItPID & " | I've made my thing! I must tell Tango T'm ready to continue.") _Task_SetVar("isBusy",0) Else _FileWriteLog($logFileCharly, "Task : "&@AutoItPID & " | No, I'm fine. ") Sleep(2000) EndIf $loop = $loop + 1 Until $loop < 50 _FileWriteLog($logFileCharly, "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($logFileTango, "Task : "&@AutoItPID,$Str) Local $loop = 0 _Task_SetVar("threadTwinTango",1) Do _FileWriteLog($logFileTango, "Task : "&@AutoItPID & " | I'm waiting TwinCharly") Sleep(1000) Until _Task_GetVar("threadTwinCharly") <> 1 _FileWriteLog($logFileTango, "Task : "&@AutoItPID & " | My twin is ready too. I can open fire...") Do If _Task_GetVar("threadTwinCharly") = 0 Then _FileWriteLog($logFileTango, "Task : "&@AutoItPID & " | My twin has stopped. I must do the same.") return EndIf If _Task_GetVar("isBusy") = 1 THEN Do _FileWriteLog($logFileTango, "Task : "&@AutoItPID & " | Charly is busy. I have to wait him") Sleep(3000) Until _Task_GetVar("isBusy") <> 1 _FileWriteLog($logFileTango, "Task : "&@AutoItPID & " | Charly is done. I can continue.") EndIf _FileWriteLog($logFileTango, "Task : "&@AutoItPID & " | I'm moving foward while Charly is covering my ass.") Sleep(1000) $loop = $loop + 1 Until $loop < 50 _FileWriteLog($logFileCharly, "Task : "&@AutoItPID & " | Tango has arrived in one piece. Thank you Charly. Over.") _Task_SetVar("threadTwinTango",0) EndFunc Opt("WinWaitDelay",100) Global Const $logFileTango = FileOpen(@ScriptDir & "\Tango.log", 1) Global Const $logFileCharly = 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($logFileTango) FileClose($logFileCharly)