[Mono-devel-list] Coroutines

Rafael Teixeira monoman at gmail.com
Tue Sep 21 13:37:33 EDT 2004


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");
}

On Mon, 20 Sep 2004 14:58:23 +0200, Joe Ante <joe at otee.dk> wrote:
> Hi,
> 
> I am using embedded mono as a scripting language runtime in our game engine
> and I would like to use coroutines to simplify some of our game code.
> 
> I want to be able to write scripts like this:
> 
> void Update ()
> {
>     Console.WriteLine ("Starting up");
>     //Yields for 20 seconds, then continues
>     WaitFor (20.F);
>     Console.WriteLine ("20 seconds later");
> }
> 
> The WaitFor function would yield back to unmanaged code.
> The unmanaged code would then simply go on, possibly calling other C#
> methods in the same class/instance.
> After 20 seconds, the engine would resume the Update method.
> 
> - I am looking for the simplest to implement solution. It does not have to
> be very fast, at least for now.
> 
> - If it is possible i would like to modify as little mcs code as possible
> since we are going to support javascript and python later on and i would
> like to be able to just put in support for other languages without having to
> make the compiler support special yield functionality.
> 
> Where do i start?
> Any idea's on how to implement this?
> Is anyone else working on it?
> 
> Joachim Ante
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 



-- 
Rafael "Monoman" Teixeira
---------------------------------------
"Eu poderia suportar, embora não sem dor, que tivessem
ido todos os meus amores, mas enlouqueceria se perdesse
todos os meus amigos!
A alguns deles não procuro, basta-me saber que eles existem.
Esta mera condição me encoraja a seguir em frente pela vida....
mas é delicioso que eu saiba e sinta que os adoro,  
embora não declare e não os procure sempre".
        Vinicius de Moraes - O "Poetinha"
My bad translation:
"I could survive, not without pain, that all my lovers
would disappear, but would be driven crazy if 
I had lost all my friends!
Some I don't even have to reach, I just need to know that they exist.
This mere condition makes me brave enough to go ahead with my life...
but it is sweet that I know and feel that I love them,
even if I don't state it openly and reach for them always."
        Vinicius de Moraes - Brazilian Poet



More information about the Mono-devel-list mailing list