Ejemplo n.º 1
0
        /// <summary>
        /// Do a step in the task. The parameter isFinal controls the completion of the task.
        /// </summary>
        /// <param name="step">The step to perform.</param>
        /// <remarks>If the step results in exception, the task is completed with that exception.</remarks>
        protected void DoStepCore(AsyncTaskStep step, bool isFinal)
        {
            Exception       exception = null;
            AsyncTaskResult result    = null;

            try
            {
                step();
                result = this.TaskResult; // If task stored it, use it.
                if (isFinal)
                {
                    this.Complete(null, result);
                }
            }
            catch (ArgumentException argexp)
            {
                exception = argexp;
            }
            catch (InvalidOperationException ioe)
            {
                exception = ioe;
            }
            catch (RealTimeException rte)
            {
                exception = rte;
            }
            catch (VoiceCompanionException vce)
            {
                exception = vce;
            }
            finally
            {
                if (result == null)
                {
                    result = new AsyncTaskResult(exception);
                }
                if (exception != null)
                {
                    result.Exception = exception;
                    this.Complete(exception, result);
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Performs the final step in the task. The completion of this step WILL complete the task.
 /// </summary>
 /// <param name="step">The final step to perform.</param>
 /// <remarks>If the step results in exception, the task is completed with that exception. Otherwise, it is completed without exception.</remarks>
 public void DoFinalStep(AsyncTaskStep step)
 {
     this.DoStepCore(step, true);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Performs a step in the task. The completion of this step DOES NOT complete the task. More steps are needed.
 /// </summary>
 /// <param name="step">The step to perform.</param>
 /// <remarks>If the step results in exception, the task is completed with that exception.</remarks>
 public void DoOneStep(AsyncTaskStep step)
 {
     this.DoStepCore(step, false);
 }