public void CanChainTasksWithoutEndWithAndThrowException()
 {
     using (var c = new ChainedOperation())
     {
         c.BeginWith(First) // first action
             .Then(Second) // second action
             .Then(Third) // third action
             .Then(Fourth); // fourth action
     }
 }
 public void CanChainTasks()
 {
     using (var c = new ChainedOperation())
     {
         c.BeginWith(First) // first action
             .Then(Second) // second action
             .Then(Third) // third action
             .Then(Fourth) // fourth action
             .EndWith(e =>
             {
                 if (e != null)
                 {
                     Trace.TraceError("An exception ocurred!");
                 }
             });
     }
 }
 static void ThirdAsync(ChainedOperation c)
 {
     Task.Factory.StartNew(() =>
     {
         //throw new Exception("Wakka");
         Trace.TraceInformation("Third (TID: {0})", Thread.CurrentThread.ManagedThreadId);
         c.Pass();
         //c.Fail();
     });
 }
 static void SecondAsync(ChainedOperation c)
 {
     Task.Factory.StartNew(() =>
     {
         Trace.TraceInformation("Second (TID: {0})", Thread.CurrentThread.ManagedThreadId);
         c.Pass();
     });
 }
 static void Third(ChainedOperation c)
 {
     // throw new Exception("Wakka");
     Trace.WriteLine("Third");
     c.Pass();
 }
 static void Second(ChainedOperation c)
 {
     Trace.WriteLine("Second");
     c.Pass();
 }
 static void Fourth(ChainedOperation c)
 {
     Trace.WriteLine("Fourth");
     c.Pass();
 }
 static void First(ChainedOperation c)
 {
     Trace.WriteLine("First");
     c.Pass();
 }
 static void CauseExceptionAsync(ChainedOperation c)
 {
     Task.Factory.StartNew(() =>
     {
         throw new Exception("Boom!!!!");
     });
 }
示例#10
0
 static void CauseException(ChainedOperation c)
 {
     throw new Exception("Boom!!!!");
 }