Ejemplo n.º 1
0
 private async void AwaitTask(LitTask task)
 {
     try{
         await task;
     }catch (System.Exception e) {
         _exception = e;
     }finally{
         _waiting = false;
     }
 }
Ejemplo n.º 2
0
        public IEnumerator ContinueWhenAll()
        {
            var startTime = System.DateTime.Now;
            var op        = new ContinueLitTaskOperation(LitTask.WhenAll(new LitTask[] {
                Delay(100),
                Delay(1000),
            }));

            yield return(op);

            Assert.Greater(DateTime.Now, startTime + TimeSpan.FromMilliseconds(1000));
        }
Ejemplo n.º 3
0
        public IEnumerator ContinueWhenAny()
        {
            var startTime = System.DateTime.Now;
            var op        = new ContinueLitTaskOperation <LitTask.WhenAnyResult>(LitTask.WhenAny(new LitTask[] {
                Delay(1000),
                Delay(100),
            }));

            yield return(op);

            Assert.GreaterOrEqual(System.DateTime.Now, startTime + System.TimeSpan.FromMilliseconds(100));
            Assert.LessOrEqual(System.DateTime.Now, startTime + System.TimeSpan.FromMilliseconds(1000));
            Assert.AreEqual(op.value.FirstCompletedTaskIndex, 1);
        }
Ejemplo n.º 4
0
        public IEnumerator AwaitWhenAnyWithExceptionLater()
        {
            var startTime = System.DateTime.Now;
            var op        = new AwaitLitTaskOperation <LitTask.WhenAnyResult>(LitTask.WhenAny(new LitTask[] {
                Delay(100),
                ThrowExceptionAfterAsync(1000),
            }));

            yield return(op);

            Assert.GreaterOrEqual(System.DateTime.Now, startTime + System.TimeSpan.FromMilliseconds(100));
            Assert.LessOrEqual(System.DateTime.Now, startTime + System.TimeSpan.FromMilliseconds(1000));
            Assert.AreEqual(op.value.FirstCompletedTaskIndex, 0);
            Assert.IsNull(op.value.Exception);
        }
Ejemplo n.º 5
0
        public IEnumerator ContinueWhenAllWithException()
        {
            System.DateTime start = System.DateTime.Now;
            var             op    = new ContinueLitTaskOperation(LitTask.WhenAll(new LitTask[] {
                Delay(100),
                ThrowExceptionAfterAsync(10),
            }));

            yield return(op);

            Assert.NotNull(op.exception);
            Assert.True(op.exception is AggregateException);
            Assert.True((op.exception as AggregateException).InnerException is TestException);
            Assert.GreaterOrEqual(DateTime.Now, start + TimeSpan.FromMilliseconds(100));
        }
Ejemplo n.º 6
0
 public ContinueLitTaskOperation(LitTask task)
 {
     task.ContinueWith(OnContinue);
 }
Ejemplo n.º 7
0
 public AwaitLitTaskOperation(LitTask task)
 {
     AwaitTask(task);
 }