public void then_long_task_is_not_completed_directly_after_begin()
        {
            const int seconds = 2;

            LongTask lt = new LongTask(seconds); // Prove that the Wait-until-done technique works
            IAsyncResult ar = lt.BeginDoTask(null, null);
            ar = lt.BeginDoTask(null, null);
            var stopwatch = System.Diagnostics.Stopwatch.StartNew();
            Assert.False(ar.IsCompleted);
        }
        public void then_long_task_is_not_completed_directly_after_begin()
        {
            const int seconds = 2;

            LongTask     lt = new LongTask(seconds);         // Prove that the Wait-until-done technique works
            IAsyncResult ar = lt.BeginDoTask(null, null);

            ar = lt.BeginDoTask(null, null);
            var stopwatch = System.Diagnostics.Stopwatch.StartNew();

            Assert.False(ar.IsCompleted);
        }
        public void then_long_task_is_completed_at_correct_time()
        {
            const int seconds = 2;

            LongTask lt = new LongTask(seconds); // Prove that the Wait-until-done technique works
            IAsyncResult ar = lt.BeginDoTask(null, null);
            ar = lt.BeginDoTask(null, null);
            var stopwatch = System.Diagnostics.Stopwatch.StartNew();
            while (!ar.IsCompleted)
            {
                Thread.Sleep(1000);
            }
            Assert.InRange(stopwatch.Elapsed.TotalSeconds, seconds, int.MaxValue);
        }
        public void then_long_task_is_completed_at_correct_time()
        {
            const int seconds = 2;

            LongTask     lt = new LongTask(seconds);         // Prove that the Wait-until-done technique works
            IAsyncResult ar = lt.BeginDoTask(null, null);

            ar = lt.BeginDoTask(null, null);
            var stopwatch = System.Diagnostics.Stopwatch.StartNew();

            while (!ar.IsCompleted)
            {
                Thread.Sleep(1000);
            }
            Assert.InRange(stopwatch.Elapsed.TotalSeconds, seconds, int.MaxValue);
        }