ID:170202
 
The code below is just a test, somethign i tried because i wanted to run 2 Procs at the same time, independantly. WHat I did below ran them one after another. The idea was to see if the text would show up in between each other, that would show that they are running at the same time, but instead it was seperate when I ran the verb.
How can I run 2 procs starting at the same time?
mob
verb/RunningProcs()
run1()
run2()

proc/run1()
usr<<"Run1"
sleep(20)
usr<<"Run1.1"
sleep(20)
usr<<"Run1.2"


proc/run2()
usr<<"Run2"
sleep(10)
usr<<"Run2.1"
sleep(10)
usr<<"Run2.2"
sleep(10)
usr<<"Run2.3"
sleep(10)
usr<<"Run2.4"
I think you can use spawn(). I am not sure.
mob/verb/runprocedure()
src.run1()
src.run2()

mob/proc
run1()
src<<"Run1"
spawn(10) src<<"Run1.1"
spawn(10) src<<"Run1.2"

run2()
src<<"Run2"
spawn(10) src<<"Run2.1"
spawn(10) src<<"Run2.2"
spawn(10) src<<"Run2.3"
spawn(10) src<<"Run2.4"


Sleep won't work because it halts the procedure until the time is up, then continues. That is why run1() and run2() aren't going at the same time, but with the spawn procedure, it should work fine. Good luck. :)
In response to Asohtra
mob
verb/RunningProcs()
spawn() run1()
spawn() run2()


Sleep won't work because it halts the procedure until the time is up, then continues. That is why run1() and run2() aren't going at the same time

you just need to use spawn() in RunningProcs. Using sleep in run1() and run2() is fine. spawn() run1() will call run1(), but it will also continue executing code. it won't wait for run1 to finish before calling run2()

In response to OneFishDown
OneFishDown wrote:
> mob
> verb/RunningProcs()
> spawn() run1()
> spawn() run2()
>

Sleep won't work because it halts the procedure until the time is up, then continues. That is why run1() and run2() aren't going at the same time

you just need to use spawn() in RunningProcs. Using sleep in run1() and run2() is fine. spawn() run1() will call run1(), but it will also continue executing code. it won't wait for run1 to finish before calling run2()


I suppose we learn something new every day. :/
In response to Asohtra
Very cool, thx for the insight!