Hi
I am trying Coroutine, but i dont understand it realy.
Could someone help me a little bit?
I am just trying to start two timers separated by buttons:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Coroutine.au3>
$Form1 = GUICreate("Form1", 156, 88, -1, -1)
$Input1 = GUICtrlCreateInput("0", 24, 16, 25, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$Input2 = GUICtrlCreateInput("0", 24, 48, 25, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
$Button1 = GUICtrlCreateButton("Button1", 72, 14, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Button2", 72, 46, 75, 25, 0)
GUISetState(@SW_SHOW)
Global $pid1, $pid2
$thread1=_CoCreate('Func timer1()|For $i=1 To 10|Return $i|Sleep(1000)|Next|EndFunc')
$thread2=_CoCreate('Func timer2()|For $i=1 To 10|Return $i|Sleep(1000)|Next|EndFunc')
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button1
$pid1=_CoStart($thread1)
Case $Button2
$pid1=_CoStart($thread2)
Case $GUI_EVENT_CLOSE
_CoCleanup()
Exit
EndSwitch
$status1=_CoStatus($pid1)
If $status1 <> '' Then GUICtrlSetData($Input1, $status1)
If $status2 <> '' Then GUICtrlSetData($Input2, $status2)
WEnd