Game Development Community

Calling function multiple times at once using schedule

by Tim Saunders · in Torque Game Builder · 08/05/2006 (2:21 am) · 3 replies

Is it possible to use the schedule command to call the same function multiple times at once? In other words, do they run like seperate threads or will the second call have to wait until the first one is finished with the function?

#1
08/05/2006 (3:05 am)
No. You can schedule a function multiple times and have the time they'll run at be the "same," however they will actually execute in the order they were scheduled.
#2
08/05/2006 (3:08 am)
The schedule command creates an event puts it into a queue that is checked in the main program loop. So if you do something like this:
$obj.schedule(10, doSomething);
$obj.schedule(10, doSomething);
$obj.schedule(10, doSomething);
then the doSomething() method will be called 2 times in sequence when main loop iterates the queue (after the 10 milliseconds are over). It is however guaranteed that the schedules with the same fire time get called in the same order that you scheduled them.
#3
08/05/2006 (3:38 am)
Oh I see, that's great thanks for your help!

Although it does mean that the reason my code isn't working is because it's rubbish code rather than the schedule doesn't do what I thought. Oh well.