示例#1
0
        public void ContinueWithで継続処理を実行できる()
        {
            var x  = 10.0;
            var x1 = Coroutines.F1(x);
            var x2 = Coroutines.F2(x1);
            var x3 = Coroutines.F3(x2);

            var task = Task.Run <double>(c => Coroutines.F1Async(x, c))
                       .OnComplete(t => Assert.AreEqual(t.Result, x1))
                       .ContinueWithIterator <string>((t, callback) => Coroutines.F2Async(t.Result, callback))
                       .OnComplete(t => Assert.AreEqual(t.Result, x2))
                       .ContinueWithIterator <int>((t, callback) => Coroutines.F3Async(t.Result, callback))
                       .OnComplete(t => Assert.AreEqual(t.Result, x2))
            ;

            var scheduler = Task.DefaultScheduler;

            scheduler.Update(30);
        }
示例#2
0
        public void ContinueWithで継続処理を実行できる()
        {
            var x  = 10.0;
            var x1 = Coroutines.F1(x);
            var x2 = Coroutines.F2(x1);
            var x3 = Coroutines.F3(x2);

            var task = new Task <double>(c => Coroutines.F1Async(x, c))
                       .OnComplete(t => Assert.AreEqual(t.Result, x1))
                       .ContinueWith <string>(Coroutines.F2Async)
                       .OnComplete(t => Assert.AreEqual(t.Result, x2))
                       .ContinueWith <int>(Coroutines.F3Async)
                       .OnComplete(t => Assert.AreEqual(t.Result, x2))
            ;

            var runner = new SampleTaskRunner.TaskRunner();

            task.Start(runner);

            runner.Update(20);
        }