示例#1
0
        public async Task TaskUtilitiesTests_WhenAllCancelTest2()
        {
            using (var verify = new Verify())
            {
                try
                {
                    var tcs1  = new TaskCompletionSource <object>();
                    var tcs2  = new TaskCompletionSource <object>();
                    var task1 = tcs1.Task;
                    var task2 = tcs2.Task;
                    var list  = new List <Task>()
                    {
                        task1, task2
                    };
                    using (var cs = new CancellationTokenSource(100))
                    {
                        var ct = cs.Token;

                        await list.WhenAll(ct);
                    }
                    verify.Fail("Error expected");
                }
                catch (OperationCanceledException)
                {
                    //Sucess
                }
            }
        }
示例#2
0
        public async Task TaskUtilitiesTests_WhenAllCancelTest2()
        {

            using (var verify = new Verify())
            {
                try
                {
                    var tcs1 = new TaskCompletionSource<object>();
                    var tcs2 = new TaskCompletionSource<object>();
                    var task1 = tcs1.Task;
                    var task2 = tcs2.Task;
                    var list = new List<Task>() { task1, task2 };
                    using (var cs = new CancellationTokenSource(100))
                    {
                        var ct = cs.Token;

                        await list.WhenAll(ct);
                    }
                    verify.Fail("Error expected");
                }
                catch (OperationCanceledException)
                {
                    //Sucess
                }
            }
        }