protected override RunStatus Run(object context) { if (!IsDone) { if (_sub == null) { if (!GetSubRoutine()) { Professionbuddy.Err("Unable to find Subroutine with name: {0}.", SubRoutineName); IsDone = true; } } if (!ranonce) { // make sure all actions within the subroutine are reset before we start. _sub.Reset(); ranonce = true; } if (_sub != null) { if (!_sub.IsRunning) { _sub.Start(SubRoutineName); } try { _sub.Tick(SubRoutineName); } catch { IsDone = true; _sub.Reset(); return(RunStatus.Failure); } IsDone = _sub.IsDone; // we need to reset so calls to the sub from other places can if (!IsDone) { return(RunStatus.Running); } } } return(RunStatus.Failure); }
protected override RunStatus Run(object context) { if (!IsDone) { if (_sub == null) { if (!GetSubRoutine()) { Professionbuddy.Err("{0}: {1}.", Pb.Strings["Error_SubroutineNotFound"], SubRoutineName); IsDone = true; } } if (!_ranonce) { // make sure all actions within the subroutine are reset before we start. if (_sub != null) { _sub.Reset(); } _ranonce = true; } if (_sub != null) { if (!_sub.IsRunning) { _sub.Start(SubRoutineName); } try { _sub.Tick(SubRoutineName); } catch (ThreadAbortException) { return(RunStatus.Success); } catch { } IsDone = _sub.IsDone; // we need to reset so calls to the sub from other places can if (!IsDone) { return(RunStatus.Success); } } } return(RunStatus.Failure); }