PDA

View Full Version : stopping a function


durf
03-31-2009, 09:50 AM
Hello,

I have def func1() and def func2() that do not run on timers of there own. I have a def maintask() that controls when each of the def() will start. The problem I am having is once func1() time has expired and func2() timer starts func1() keeps runnning.


def MainTask():

#Run func1 for 10 seconds
timer = vizact.ontimer2(0,0,func1)
yield viztask.waitTime(10)
timer.remove()

#Run func2 for 10 seconds
timer = vizact.ontimer2(0,0,func2)
yield viztask.waitTime(10)
timer.remove()

#Quit script
timer = vizact.ontimer2(0,0,func3)
yield viztask.waitTime(viz.FOREVER)

viztask.schedule( MainTask() )



how do I stop func1() from running once func2() has started?

I can supply more code if need be. Just looking for an example

masaki
03-31-2009, 04:45 PM
in order to kill a vizact timer, use the following code:
timer.setEnabled(viz.OFF)

if you want to kill a viztask function use the following code:
task = viztask.schedule( sometask() )
task.kill()


-masaki