Example #1
0
 private void EnumerateSteps()
 {
     if (base.Task.IsCompleted)
     {
         return;
     }
     if (!this.steps.MoveNext())
     {
         this.StepsComplete();
         return;
     }
     this.currentStep = this.steps.Current;
     this.currentStep.Task.ContinueWith((System.Threading.Tasks.Task t) => {
         if (t.IsCanceled)
         {
             if (this.currentStep.Policy == IteratorTask <TResult> .ExceptionPolicy.Transfer)
             {
                 base.TrySetCanceled();
                 this.StepsComplete();
             }
             return;
         }
         if (t.IsFaulted && this.currentStep.Policy == IteratorTask <TResult> .ExceptionPolicy.Transfer)
         {
             this.DoSetException(t.Exception.GetBaseException());
             this.StepsComplete();
             return;
         }
         try
         {
             this.EnumerateSteps();
         }
         catch (Exception exception1)
         {
             Exception exception = exception1;
             if (Fx.IsFatal(exception))
             {
                 throw;
             }
             this.DoSetException(exception);
         }
     }, TaskContinuationOptions.ExecuteSynchronously);
 }
Example #2
0
 protected IteratorTask <TResult> .TaskStep CallTask(System.Threading.Tasks.Task task, IteratorTask <TResult> .ExceptionPolicy policy = 0)
 {
     return(new IteratorTask <TResult> .TaskStep(task, policy));
 }
Example #3
0
 protected IteratorTask <TResult> .TaskStep CallTask <TState>(Func <TState, System.Threading.Tasks.Task> taskFunc, TState state, IteratorTask <TResult> .ExceptionPolicy policy = 0)
 {
     System.Threading.Tasks.Task task;
     if (policy != IteratorTask <TResult> .ExceptionPolicy.Continue)
     {
         task = taskFunc(state);
     }
     else
     {
         try
         {
             task = taskFunc(state);
         }
         catch (Exception exception1)
         {
             Exception exception = exception1;
             if (Fx.IsFatal(exception))
             {
                 throw;
             }
             TaskCompletionSource <object> taskCompletionSource = new TaskCompletionSource <object>();
             taskCompletionSource.SetException(exception);
             task = taskCompletionSource.Task;
         }
     }
     return(new IteratorTask <TResult> .TaskStep(task, policy));
 }
Example #4
0
 public TaskStep(System.Threading.Tasks.Task task, IteratorTask <TResult> .ExceptionPolicy policy)
 {
     this.task   = task;
     this.policy = policy;
 }