[Mono-devel-list] Coroutines
Joe Ante
joe at otee.dk
Tue Sep 21 14:32:53 EDT 2004
Hi Miguel and Rafael,
> I agree with Miguel, that you don't need specific CoRoutines support,
> just use the Thread class.
>
> Your code could be transformed in
>
> void Update ()
> {
> Console.WriteLine ("Starting up");
> System.Threading.Thread.Sleep(20000); // every other thread will
> continue to execute
> Console.WriteLine ("20 seconds later");
> }
I am looking for something less heavyweight than threads.
The game code i am running needs to run synchronously. Also the WaitFor
function was an example and there might be several other Yielding function's
eg. WaitForAnimationToFinish
I guess i could do something like create a seperate thread for every update
function which might contain a yield statement. Something like this.
Create Update Function Thread
Suspend MainThread
Run Update Function Thread
void Update ()
{
WaitFor (20.F)
{
Store info about this thread and when to continue the thread
Suspend Update function thread
Run MainThread
}
}
Some time later from inside the MainThread when 20 seconds have passed or an
animation finished playing call:
Suspend MainThread
Run UpdateThread (This would then finish the update function)
Run MainThread
You are right that it's simplest to implement but i don't think it's gonna
cut it performance wise.
I really want to start working a bit on coroutines. I'd really appreciate if
you can give me some hints, starters, help.
Joachim Ante
More information about the Mono-devel-list
mailing list