This code need to run forever, untill the program is closed.
What i got for now:
Code: Select all
EnableExplicit
Procedure Thread1()
Define hEvent.l
hEvent = CreateEvent_(#Null, #True, #False, #Null$)
If hEvent
WaitForSingleObject_(hEvent, 2000)
CloseHandle_(hEvent)
Debug "Task each 2 seconds"
Thread1()
EndIf
EndProcedure
Procedure Thread2()
Define hEvent.l
hEvent = CreateEvent_(#Null, #True, #False, #Null$)
If hEvent
WaitForSingleObject_(hEvent, 6000)
CloseHandle_(hEvent)
Debug "Task each 6 seconds"
Thread2()
EndIf
EndProcedure
Procedure Main()
Define hEvent.l
Dim Threads.l(1)
Threads(0) = CreateThread_(#Null, 0, @Thread1(), #Null, 0, #Null)
Threads(1) = CreateThread_(#Null, 0, @Thread2(), #Null, 0, #Null)
WaitForMultipleObjects_(2, @Threads(), #True, #INFINITE)
CloseHandle_(Threads(0))
CloseHandle_(Threads(1))
EndProcedure
Main()
Also, i want to do all this without using Sleep, as sleep will pause whole program and not only the thread.
Thanks for you time