Thread: Timer Question
View Single Post
  #2  
Old 03-24-2009, 09:57 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Here is an example that uses the viztask module to control the timing of the 3 different functions:
Code:
import viz
import vizact
import viztask
viz.go()

def func1():
	pass
	
def func2():
	pass
	
def func3():
	pass

def MainTask():
	
	#Run func1 for 3 minutes
	timer = vizact.ontimer(0,func1)
	yield viztask.waitTime(180)
	timer.remove()
	
	#Run func2 for 4 minutes
	timer = vizact.ontimer(0,func2)
	yield viztask.waitTime(240)
	timer.remove()
	
	#Run func3 for 3 minutes
	timer = vizact.ontimer(0,func3)
	yield viztask.waitTime(180)
	timer.remove()
	
	#Quit script
	viz.quit()
	
viztask.schedule( MainTask() )
Reply With Quote