Пример #1
0
        public void TryExecuteTaskInline_QueuedTask()
        {
            var scheduler = new TestableScheduler(concurrency: 1);
            var task0     = null as Task;
            var task1     = ATask();
            var task2     = ATask();

            task0 = new Task(() =>
            {
                // Now inside dispatcher thread
                scheduler
                .TryExecuteTaskInline(task1, taskWasPreviouslyQueued: true)
                .Should().BeTrue();
            });

            task0.Start(scheduler);
            task1.Start(scheduler);
            scheduler.IsDispatcherEnabled = true;
            task2.Start(scheduler);

            Task.WaitAll(task0, task1, task2);
        }
Пример #2
0
        public void TryExecuteTaskInline_NotInDispatcherThread()
        {
            var scheduler = new TestableScheduler();

            scheduler.TryExecuteTaskInline(ATask(), false).Should().BeFalse();
        }
Пример #3
0
        public void TryExecuteTaskInline_NullTask()
        {
            var scheduler = new TestableScheduler();

            scheduler.TryExecuteTaskInline(null, false).Should().BeFalse();
        }