Write an example of a Task.WhenAll (t) of.

 public static void Main()
        {

            var t = Task.Run(() =>
            {
                throw new Exception("aa");
            });

            Task.Factory.ContinueWhenAll(new Task[] { t }, (tt) =>
            {
                Thread.Sleep(1000);
                Console.WriteLine(tt[0].Exception.InnerException.Message);
            });

            Task.WhenAll(t).ContinueWith(tt =>
            {
                if (tt.Exception != null)
                {
                    Thread.Sleep(1000);
                    Console.WriteLine(tt.Exception.InnerException.Message);
                }
            });
            Console.WriteLine("over一秒后");
            Console.ReadKey();
        }

A very simple example, one can tell how fat things.

Print Results:

After over one second

aa

aa

Guess you like

Origin www.cnblogs.com/zhuwansu/p/11237594.html