Timing a thread
Posted: Wed Feb 23, 2005 3:13 am
I need to execute stuff in a seperate thread about very two seconds, instead of having it repeat over and over without pause.
i tried with ElapsedMillisecs() and this works, until one goes to a different program and come back, then it has magically stopped timing which makes my thread not do anything anymore (which is not what i want).
So, the above code WORKS, until the app looses focus then somehow the thread doesn't work anymore. I need this to work no matter if the app has focus or not (and definitely it should work if the app gains focus again)
Any ideas?
Tim
i tried with ElapsedMillisecs() and this works, until one goes to a different program and come back, then it has magically stopped timing which makes my thread not do anything anymore (which is not what i want).
Code: Select all
Declare threadthingamabob(whatever)
win = OpenWindow(1,100,100,200,200,0,"hmm")
thread = CreateThread(@threadthingamabob(),0)
Repeat
Eventid.l = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow ; If the user has pressed on the close button
Quit = 1
EndIf
Until Quit = 1
Procedure threadthingamabob(whatever)
Start = 0
Repeat
If Start = 0
Start = ElapsedMilliseconds()
EndIf
If ElapsedMilliseconds() - Start => 1999
Debug "THREAD EXECUTE"
; do stuff
Start = 0
EndIf
ForEver
EndProcedure
Any ideas?
Tim