Example #1
0
        public IEnumerator testWaitForAnyExceptionTyped()
        {
            bool      hasDetectedException = false;
            Exception e;
            var       doneA = false;
            var       doneB = false;

            async Routine <int> waitShort()
            {
                await RoutineBase.WaitForNextFrame();

                await RoutineBase.WaitForNextFrame();

                doneA = true;
                throw new Exception();
            }

            async Routine <int> waitLong()
            {
                await RoutineBase.WaitForNextFrame();

                await RoutineBase.WaitForNextFrame();

                await RoutineBase.WaitForNextFrame();

                doneB = true;
                return(5);
            }

            async Routine testWaitForAny()
            {
                try
                {
                    await RoutineBase.WaitForAny(waitShort(), waitLong());
                }
                catch (Exception ex)
                {
                    hasDetectedException = true;
                }
            }

            var handle = manager.Run(testWaitForAny());

            Assert.IsFalse(doneA);
            Assert.IsFalse(doneB);
            Assert.IsFalse(handle.IsDead);
            yield return(null);

            yield return(null);

            Assert.IsTrue(doneA);
            Assert.IsFalse(doneB);
            Assert.IsTrue(handle.IsDead);
            Assert.IsTrue(hasDetectedException);

            yield return(null);

            Assert.IsTrue(doneA);
            Assert.IsFalse(doneB);
        }
Example #2
0
 private async Routine testExceptionCatch()
 {
     try
     {
         await RoutineBase.WaitForNextFrame();
         await throwEx();
     }
     catch (Exception e)
     {
         exceptionCaught = true;
     }
 }
Example #3
0
        public IEnumerator testWaitForAny()
        {
            Exception e;
            var       doneA = false;
            var       doneB = false;

            async Routine waitShort()
            {
                await RoutineBase.WaitForNextFrame();

                doneA = true;
            }

            async Routine waitLong()
            {
                await RoutineBase.WaitForNextFrame();

                await RoutineBase.WaitForNextFrame();

                doneB = true;
            }

            async Routine testWaitForAny()
            {
                await RoutineBase.WaitForAny(waitShort(), waitLong());
            }

            var handle = manager.Run(testWaitForAny());

            Assert.IsFalse(doneA);
            Assert.IsFalse(doneB);
            Assert.IsFalse(handle.IsDead);
            yield return(null);

            Assert.IsTrue(doneA);
            Assert.IsFalse(doneB);
            Assert.IsTrue(handle.IsDead);

            yield return(null);

            Assert.IsTrue(doneA);
            Assert.IsFalse(doneB);
        }