Exemple #1
0
        public void SequencedWorkTest()
        {
            var sequence = new SequencedWork<String>()
                           {
                               Begin = () => "Start",
                               Cleanup = task => Console.WriteLine("I'm cleaning {0}", task),
                               End = task => Console.WriteLine("Result: {0}\nEnd",task.Result),
                               Error = task => Console.WriteLine("{0}:\n{1}", task.Exception.Flatten().Message, task.Exception.Flatten().StackTrace),
                               intermediates = new List<Func<Task<string>, string>>()
                                               {
                                                   task => task.Result + "\nintermediate1",
                                                   task => task.Result + "\nintermediate2",
                                                   task => task.Result + "\nintermediate3"
                                               }
                           };

            sequence.Run();
        }
Exemple #2
0
        public void SequencedWorkExceptionTest()
        {
            var sequence = new SequencedWork<String>()
            {
                Begin = () => "Start",
                Cleanup = task => Console.WriteLine("I'm cleaning {0}", task),
                End = task => Console.WriteLine("Result: {0}\nEnd", task.Result),
                Error = task => Console.WriteLine("{0}", task.Exception.GetBaseException()),
                intermediates = new List<Func<Task<string>, string>>()
                                               {
                                                   task => task.Result + "\nintermediate1",
                                                   task => task.Result + "\nintermediate2",
                                                   task => {throw new ArgumentException("generic argument exception");}
                                               }
            };

            sequence.Run();
        }