/// <summary>
 /// When the sub-algorithm is completed this reverts us to listening to local progress
 /// </summary>
 /// <param name="childAlgorithm"></param>
 protected void StopListenToProgress(AlgorithmBase childAlgorithm)
 {
     ValidateArg.IsNotNull(childAlgorithm, "childAlgorithm");
     childAlgorithm.ProgressChanged -= NotifyProgressChanged;
     progressRatio = stageEndRatio;
     stageStartRatio = 0;
     stageEndRatio = 1;
 }
 /// <summary>
 /// Runs the child algorithm and listens for progress changes.
 /// </summary>
 protected void RunChildAlgorithm(AlgorithmBase childAlgorithm, double stageRatio)
 {
     ValidateArg.IsNotNull(childAlgorithm, "childAlgorithm");
     try
     {
         StartListenToProgress(childAlgorithm, stageRatio);
         childAlgorithm.Run();
     }
     finally
     {
         StopListenToProgress(childAlgorithm);
     }
 }
 /// <summary>
 /// When starting a sub-algorithm start listening to its progress, transforming
 /// the progressRatio it reports (between 0 and 1) to between progressRatio and progressRatio+stageRatio
 /// </summary>
 /// <param name="childAlgorithm">The child algorithm.</param>
 /// <param name="stageRatio">The fraction of time the child algorithm will take of the parent algorithm.</param>
 protected void StartListenToProgress(AlgorithmBase childAlgorithm, double stageRatio)
 {
     ValidateArg.IsNotNull(childAlgorithm, "childAlgorithm");
     childAlgorithm.ProgressChanged += NotifyProgressChanged;
     stageStartRatio = progressRatio;
     stageEndRatio = progressRatio + stageRatio;
 }