public void Test() { ProgressTracker pt = new ProgressTracker(); TestProcess tp = new TestProcess(); pt.ProgressChanged += new EventHandler(pt_ProgressChanged); tp.Process(pt, 4); }
protected override void Perform() { pt = new ProgressTracker(); BurrowFramework bf = new BurrowFramework(); bf.InitWorkSpace(); try { pt.ProgressChanged += new EventHandler(pt_ProgressChanged); DoPerform(); }catch(Exception) { try { if (bf.CurrentConversation != null) bf.CurrentConversation.GiveUp(); }catch (Exception) {/*prevent this exception hiding the real one*/} throw; } finally { try { bf.CloseWorkSpace(); } catch (Exception) {/*prevent this exception hiding the real one*/} } }
public void Process(ProgressTracker progressTracker, int maximumNumOfSubs) { if (maximumNumOfSubs > 0) for (int i = 0; i < maximumNumOfSubs; i++) Process(progressTracker.CreateSubTracker(maximumNumOfSubs), maximumNumOfSubs - 1); }
/// <summary> /// /// </summary> /// <param name="totalNumberOfSteps"></param> /// <param name="thisSubProcFinishingStep">the finishing number of Step once this current sub process finishes</param> /// <returns></returns> public ProgressTracker CreateSubTracker(int totalNumberOfSteps, int thisSubProcFinishingStep) { numOfSubProcedure = totalNumberOfSteps; if (numOfSubProcedure <= 0) throw new Exception("Cannot enter sub procedure if tracker created with 0 number of sub procedure"); subTracker = new ProgressTracker(); subTracker.ProgressChanged += new EventHandler(subTracker_ProgressChanged); currentSubProcIdx = thisSubProcFinishingStep; if (currentSubProcIdx > 0) FireProgressChangedEvt(); return subTracker; }
public static ProgressTracker CreateSubTracker(ProgressTracker currentTracker, int numberOfSubProc) { if (currentTracker != null) return currentTracker.CreateSubTracker(numberOfSubProc); else return null; }