Esempio n. 1
0
        public static IEnumerator TestThing(Channel c)
        {
            //does not block and continues directly
            yield return c.ListenForInput(p => {
                Console.WriteLine("non blocking: " + p.ToString());
            });

            yield return c.WaitForChannelChange();
            Console.WriteLine("change");
            yield return c.WaitForChannelChange();
            Console.WriteLine("channel changed again");

            object o = null;
            //blocks and waits for input
            yield return c.WaitForInput((p) => {
                o = p;
            });

            Console.WriteLine("second blocking: " + o);

            while (c.length > 0)
            {
                Console.WriteLine("#" + c.Pull());
            }

            yield break;
        }
Esempio n. 2
0
        public static IEnumerator TestThong(Channel c)
        {
            c.Push("I wonder who catches this first");
            yield return new Routinely.WaitForNextFrame();
            yield return new Routinely.WaitForNextFrame();
            yield return new Routinely.WaitForNextFrame();
            yield return new Routinely.WaitForNextFrame();
            c.Push("Second thing");
            yield return new Routinely.WaitForNextFrame();
            yield return new Routinely.WaitForNextFrame();
            yield return new Routinely.WaitForNextFrame();
            yield return new Routinely.WaitForNextFrame();

            c.Push("3 thing");
            c.Push("4 thing");
            c.Push("5 thing");
            c.Push("6 thing");
            yield return new Routinely.WaitForNextFrame();
            yield return new Routinely.WaitForNextFrame();
            yield return new Routinely.WaitForNextFrame();
            yield return new Routinely.WaitForNextFrame();

            c.Push("7 thing");
            yield return new Routinely.WaitForNextFrame();
            yield return new Routinely.WaitForNextFrame();
            yield return new Routinely.WaitForNextFrame();
            yield return new Routinely.WaitForNextFrame();
        }
Esempio n. 3
0
 public static void Main(string[] args)
 {
     Routinely m = new Routinely();
     Channel c = new Channel();
     m.Run(TestThing(c));
     m.Run(TestThong(c));
     for (int i = 0; i < 1000; i++)
     {
         m.Update();
     }
 }