Beispiel #1
0
        public async Task TaskUtilitiesTests_WhenAllCancelTest1()
        {
            using (var verify = new Verify())
            {
                var task1 = Task.Delay(TimeSpan.FromMilliseconds(100));
                var task2 = Task.Delay(TimeSpan.FromMilliseconds(125));
                var task3 = Task.Delay(TimeSpan.FromMilliseconds(150));
                var list  = new List <Task>()
                {
                    task1, task2, task3
                };
                using (var cs = new CancellationTokenSource())
                {
                    var ct = cs.Token;

                    await list.WhenAll(ct);
                }
                verify.IsTrueForAll(list, t => t.IsCompleted, "All tasks should have been completed.");
            }
        }
Beispiel #2
0
        public async Task TaskUtilitiesTests_WhenAllCancelTest1()
        {
            using (var verify = new Verify())
            {
                var task1 = Task.Delay(TimeSpan.FromMilliseconds(100));
                var task2 = Task.Delay(TimeSpan.FromMilliseconds(125));
                var task3 = Task.Delay(TimeSpan.FromMilliseconds(150));
                var list = new List<Task>() { task1, task2, task3 };
                using (var cs = new CancellationTokenSource())
                {
                    var ct = cs.Token;

                    await list.WhenAll(ct);
                }
                verify.IsTrueForAll(list, t => t.IsCompleted, "All tasks should have been completed.");
            }
        }