using nft.framework;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace nft.test.test {
    class FiberSample {
        [TestEntry]
        public static bool Test() {
            FiberManager fm = new FiberManager();
            FiberSample sample = new FiberSample();
            fm.Add(sample.FiberProc1());
            fm.Add(sample.FiberProc2());
            fm.Add(sample.FiberProc3());
            while (fm.ProcessFibers() > 0) ;
            return true;
        }

        IEnumerable FiberProc3() {
            for (int i = 1; i < 3; i++) {
                Debug.Print("Fiber#3-Step" + i);
                yield return null;
            }
            yield break;
        }

        IEnumerable FiberProc2() {
            for (int i = 1; i < 5; i++) {
                Debug.Print("Fiber#2-Step" + i);
                yield return null;
            }
            yield break;
        }

        IEnumerable FiberProc1() {
            Debug.Print("Fiber#1-Step1");
            yield return null;
            Debug.Print("Fiber#1-Step2");
            yield return null;
            Debug.Print("Fiber#1-Step3");
            yield break;
        }
    }
    
}
