#include #include #include HotKeySet("x","ExitProgram") Func TwinCharly() Local $logFile = FileOpen(@ScriptDir & "\Charly.log", 1) local $infoarray=_Task_info() _FileWriteLog($logFile, "Task : "&@AutoItPID & " " & "| Hello I'm "&$infoarray[0]& " ; I am executing "&$infoarray[1]&" and my parent Process PID is : "&$infoarray[2]) _Task_SetVar("threadTwinCharly",1) Local $loop = 0 While _Task_GetVar("threadTwinTango") = 0 sleep(200) _FileWriteLog($logFile, "Task : "&@AutoItPID & " | I'm waiting TwinTango") WEnd _FileWriteLog($logFile, "Task : "&@AutoItPID & " | My twin is ready too. I have to start coring the back while Tango is leading the way...") While $loop < 7 If _Task_GetVar("threadTwinTango") = 0 Then _FileWriteLog($logFile, "Task : "&@AutoItPID & " | My twin has stopped. I must do the same.") return EndIf _FileWriteLog($logFile, "Task : "&@AutoItPID & " | Are we in combat ? ") If Mod($loop,3) = 0 THEN _FileWriteLog($logFile, "Task : "&@AutoItPID & " | Yes! I must tell Tango i'm busy.") _Task_SetVar("isBusy",1) Sleep(5000) _FileWriteLog($logFile, "Task : "&@AutoItPID & " | I've made my thing! I must tell Tango T'm ready to continue.") _Task_SetVar("isBusy",0) Else _FileWriteLog($logFile, "Task : "&@AutoItPID & " | No, I'm fine. ") Sleep(1000) EndIf $loop = $loop + 1 WEnd _FileWriteLog($logFile, "Task : "&@AutoItPID & " | I (Charly) am dead before Tango arrives.") _Task_SetVar("threadTwinCharly",0) FileClose(@ScriptDir & "\Charly.log") EndFunc func TwinTango() Local $logFile = FileOpen(@ScriptDir & "\Tango.log", 1) local $infoarray=_Task_info() _FileWriteLog($logFile, "Task : "&@AutoItPID & " " & "| Hello I'm "&$infoarray[0]& " ; I am executing "&$infoarray[1]&" and my parent Process PID is : "&$infoarray[2]) _Task_SetVar("threadTwinTango",1) Local $loop = 0 While _Task_GetVar("threadTwinCharly") = 0 sleep(200) _FileWriteLog($logFile, "Task : "&@AutoItPID & " | I'm waiting TwinCharly") WEnd _FileWriteLog($logFile, "Task : "&@AutoItPID & " | My twin is ready too. I can open start moving...") While $loop < 7 If _Task_GetVar("threadTwinCharly") = 0 Then _FileWriteLog($logFile, "Task : "&@AutoItPID & " | My twin has died. I'm going to die too...") return EndIf If _Task_GetVar("isBusy") = 1 THEN While _Task_GetVar("isBusy") = 1 _FileWriteLog($logFile, "Task : "&@AutoItPID & " | Charly is busy. I have to wait him") Sleep(1000) WEnd _FileWriteLog($logFile, "Task : "&@AutoItPID & " | Charly is done. I can continue.") EndIf _FileWriteLog($logFile, "Task : "&@AutoItPID & " | I'm moving foward while Charly is covering my ass.") Sleep(1000) $loop = $loop + 1 WEnd _FileWriteLog($logFile, "Task : "&@AutoItPID & " | Tango has arrived in one piece. Thank you Charly. Over.") _Task_SetVar("threadTwinTango",0) FileClose(@ScriptDir & "\Tango.log") EndFunc Func ExitProgram() Exit EndFunc Opt("WinWaitDelay",100) _Task_SetVar("threadTwinCharly",0) _Task_SetVar("threadTwinTango",0) _Task_SetVar("isBusy",0) local $PIDarray[2] $PIDarray[0]=_Task_Create("Charly","TwinCharly") $PIDarray[1]=_Task_Create("Tango","TwinTango") ConsoleWrite("Main Process PID: " & @AutoItPID & " -> Tango and Charly are ready Good luck boys." & @LF) local $tasks[2]=["Charly","Tango"] _TasK_Join($tasks) ConsoleWrite("Main Process : Thanx and Good Bye" & @LF)