public void AllComplete_ExecutesCallbackWhenSomeDiscardedSomeCompleted()
        {
            var run = false;

            var s = MockMaker.Empty<IScheduler>();

            var t1 = new DelegateBasedAsyncTask(s);
            var t2 = new DelegateBasedAsyncTask(s);

            var l = new List<AsyncTask>()
            {
                t1,
                t2
            };

            l.AllComplete((_) =>
            {
                run = true;
            });

            t1.HandleTaskDiscarded();
            t2.HandleTaskCompletion();

            Assert.True(run);
        }
 /// <summary>
 /// Add a new task to the scheduler to be executed and after that run a
 /// follow-up task.
 /// </summary>
 /// <param name="a">The task to be run in the scheduler</param>
 /// <param name="h">The follow up handler to be executed</param>
 private void RunOnSchedulerSync(Action a, AsyncTaskCompletedHandler h)
 {
     var task = new DelegateBasedAsyncTask(scheduler, a);
     task.ThenPost(h, DispatcherSynchronizationContext.Current);
     scheduler.ScheduleForExecution(task);
 }
        public void AllComplete_ReturnsDisposableThatDisposesAllRegistrations()
        {
            var run = false;

            var s = MockMaker.Empty<IScheduler>();

            var t1 = new DelegateBasedAsyncTask(s);
            var t2 = new DelegateBasedAsyncTask(s);

            var l = new List<AsyncTask>()
            {
                t1,
                t2
            };

            l.AllComplete((_) =>
            {
                run = true;
            }).Dispose();

            t1.HandleTaskCompletion();
            t2.HandleTaskDiscarded();

            Assert.False(run);
        }