Example #1
0
        void MyCompletion(TaskServiceCompletionType flag, Exception ex)
        {
            // set this *before* unblocking the countdown
            taskCompletionFlag = flag;

            // when the task runner calls here, this will unblock the countdown in the unit test function so it can test the expected completion type
            caller_countdown.Signal();
        }
Example #2
0
        public void TestParallelCancelled()
        {
            taskCompletionFlag = TaskServiceCompletionType.Undefined;
            caller_countdown   = new CountdownEvent(1);

            var service = new ParallelTaskRunner();

            cancellationTokenSource = service.RunTasks(items, MyWorkCancelled, MyProgress, MyCompletion, 4);

            caller_countdown.Wait();
            Assert.IsTrue(taskCompletionFlag == TaskServiceCompletionType.Cancelled, string.Format("Completion flag is {0}", taskCompletionFlag));
        }
Example #3
0
        public void TestSequentialException()
        {
            taskCompletionFlag = TaskServiceCompletionType.Undefined;

            // wait for the completion function to be called
            caller_countdown = new CountdownEvent(1);

            var service = new SequentialTaskRunner();

            cancellationTokenSource = service.RunTasks(items, MyWorkException, MyProgress, MyCompletion, 4);

            caller_countdown.Wait();
            Assert.IsTrue(taskCompletionFlag == TaskServiceCompletionType.Exception, string.Format("Completion flag is {0}", taskCompletionFlag));
        }