delay

Archives Forums/MacOS X Discussion/delay

Panno(Posted 2014) [#1]
hi ,
i build a small tool to get and send my external ip every xxx minutes to a server.

i use delay xxx to create a pause but osx shows me the beach ball.

any better tips ?


do
make something
delay xxxx
loop


AdamStrange(Posted 2014) [#2]
use a timer event
with a delay in the loop:
SuperStrict

Graphics 640,480


EnablePolledInput()
Local AppQuit:Int = False
Local AppQueue:Int 

Local Timer:TTimer
Local nHertz:Int = 10000 ' 1 second
Timer = CreateTimer(nHertz)
		
'stoptimer
'If Timer StopTimer Timer
		
While Not AppQuit
	AppQueue = PollEvent()
	If AppQueue = 0 Then
		Delay(2)
	Else
		Select EventID()
			Case EVENT_TIMERTICK
				Print "hello t="+MilliSecs()
			Case EVENT_APPTERMINATE, EVENT_WINDOWCLOSE 
				AppQuit = True
		End Select
	End If
wend


this is how all programs should be setup in any modern OS so that multitasking operates correctly. There are other ways, but this is the simplest


Panno(Posted 2014) [#3]
it seems i play to long with my pic32.
thx a lot


AdamStrange(Posted 2014) [#4]
lol, what are you doing with the pic?
Yep multitasking needs a slight change, but not too much ...


Panno(Posted 2014) [#5]
https://youtube.com/user/plasmamac