Пример #1
0
 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
     }
 }
Пример #2
0
 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!");
                 }
             });
     }
 }
Пример #3
0
 static void ThirdAsync(ChainedOperation c)
 {
     Task.Factory.StartNew(() =>
     {
         //throw new Exception("Wakka");
         Trace.TraceInformation("Third (TID: {0})", Thread.CurrentThread.ManagedThreadId);
         c.Pass();
         //c.Fail();
     });
 }
Пример #4
0
 static void SecondAsync(ChainedOperation c)
 {
     Task.Factory.StartNew(() =>
     {
         Trace.TraceInformation("Second (TID: {0})", Thread.CurrentThread.ManagedThreadId);
         c.Pass();
     });
 }
Пример #5
0
 static void Third(ChainedOperation c)
 {
     // throw new Exception("Wakka");
     Trace.WriteLine("Third");
     c.Pass();
 }
Пример #6
0
 static void Second(ChainedOperation c)
 {
     Trace.WriteLine("Second");
     c.Pass();
 }
Пример #7
0
 static void Fourth(ChainedOperation c)
 {
     Trace.WriteLine("Fourth");
     c.Pass();
 }
Пример #8
0
 static void First(ChainedOperation c)
 {
     Trace.WriteLine("First");
     c.Pass();
 }
Пример #9
0
 static void CauseExceptionAsync(ChainedOperation c)
 {
     Task.Factory.StartNew(() =>
     {
         throw new Exception("Boom!!!!");
     });
 }
Пример #10
0
 static void CauseException(ChainedOperation c)
 {
     throw new Exception("Boom!!!!");
 }