예제 #1
0
        public static void TaskWithResultTest()
        {
            var task = Task <long> .Factory.StartNew(() => 42);

            task.Wait();
            var awaiter = Awaitable <Task <long>, TaskAwaiter <long>, long> .GetAwaiter(task);

            True(NotifyCompletion <TaskAwaiter <long> > .IsCompleted(awaiter));
            Equal(42, Awaiter <TaskAwaiter <long>, long> .GetResult(awaiter));
        }
예제 #2
0
        public static void TaskWithoutResultTest()
        {
            var holder = new ValueHolder();
            var task   = Task.Factory.StartNew(holder.ChangeValue);

            task.Wait();
            var awaiter = Awaitable <Task, TaskAwaiter> .GetAwaiter(task);

            True(NotifyCompletion <TaskAwaiter> .IsCompleted(awaiter));
            Awaiter <TaskAwaiter> .GetResult(awaiter);

            Equal(42, holder.Value);
        }