#include #include #include Func TwinCharly() Local $logFile = FileOpen(@ScriptDir & "\Charly.log", 1) local $infoarray=_Task_info() _FileWriteLog($logFile, "Task : "&@AutoItPID & " " & "| Hello I'm "&$infoarray[0]& "I Executing "&$infoarray[1]&"And my parent Process PID is :"&$infoarray[2]) _Task_SetVar("threadTwinCharly",1) Local $loop = 0 Do _FileWriteLog($logFile, "Task : "&@AutoItPID & " | I'm waiting TwinTango") Sleep(1000) Until _Task_GetVar("threadTwinTango") = 0 _FileWriteLog($logFile, "Task : "&@AutoItPID & " | My twin is ready too. I can open fire...") Do If _Task_GetVar("threadTwinCharly") 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(2000) EndIf $loop = $loop + 1 Until $loop < 50 _FileWriteLog($logFile, "Task : "&@AutoItPID & " | Charly is dead before Tango arrives. Over.") _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 Executing "&$infoarray[1]&"And my parent Process PID is :"&$infoarray[2]) _Task_SetVar("threadTwinTango",1) Local $loop = 0 Do _FileWriteLog($logFile, "Task : "&@AutoItPID & " | I'm waiting TwinCharly") Sleep(1000) Until _Task_GetVar("threadTwinCharly") = 0 _FileWriteLog($logFile, "Task : "&@AutoItPID & " | My twin is ready too. I can open fire...") Do If _Task_GetVar("threadTwinCharly") = 0 Then _FileWriteLog($logFile, "Task : "&@AutoItPID & " | My twin has stopped. I must do the same.") return EndIf If _Task_GetVar("isBusy") = 1 THEN Do _FileWriteLog($logFile, "Task : "&@AutoItPID & " | Charly is busy. I have to wait him") Sleep(3000) Until _Task_GetVar("isBusy") <> 1 _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 Until $loop < 50 _FileWriteLog($logFile, "Task : "&@AutoItPID & " | Tango has arrived in one piece. Thank you Charly. Over.") _Task_SetVar("threadTwinTango",0) FileClose(@ScriptDir & "\Tango.log") EndFunc Opt("WinWaitDelay",100) _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") ;====> Only main process can use _Task_Create to prevent Process Loop _Task_Create("Tango","TwinTango") local $tasks[2]=["Charly","Tango"] _TasK_Join($tasks) ConsoleWrite("Main Process : Thanx and Good Bye" & @LF)