Exemple #1
0
 /// <summary>
 /// 异步操作:退出
 /// </summary>
 public override void Exit()
 {
     if (0 == _status || 3 == _status)
     {
         return;
     }
     _status = 3;
     if (2 == _status)
     {
         _eventCmd.Set();
     }
     if (InnerFlow.Stop(10) != JFWorkCmdResult.Success)
     {
         InnerFlow.Abort();
     }
 }
Exemple #2
0
        public override bool Action()
        {
            _actionStartPerformance = JFFunctions.PerformanceCounter();

            _status = 1;
            _eventCmd.Set();
            if (!IsInitOK)
            {
                _actionStopPerformance = JFFunctions.PerformanceCounter();
                _actionErrorInfo       = "Action failed by:is not init OK,initError:" + GetInitErrorInfo();
                _status = 0;
                return(false);
            }

            try
            {
                if (_isIncludeEnd)      //包含结束值
                {
                    if (_interval >= 0) //正向增加
                    {
                        for (_forValue = _startValue; _forValue <= _endValue; _forValue += _interval)
                        {
                            InnerFlow.DataPool["For_Value"] = _forValue;
                            if (!InnerFlow.Action())
                            {
                                _status = 0;
                                _actionStopPerformance = JFFunctions.PerformanceCounter();
                                return(false);
                            }
                            if (2 == _status)
                            {
                                _eventCmd.WaitOne();
                                if (3 == _status)
                                {
                                    _status = 0;
                                    _actionStopPerformance = JFFunctions.PerformanceCounter();
                                    if (InnerFlow.Stop(10) != JFWorkCmdResult.Success)
                                    {
                                        InnerFlow.Abort();
                                    }
                                    throw new JFBreakMethodFlowException();
                                }
                            }
                        }
                    }

                    else //负向递减
                    {
                        for (_forValue = _startValue; _forValue >= _endValue; _forValue += _interval)
                        {
                            InnerFlow.DataPool["For_Value"] = _forValue;
                            if (!InnerFlow.Action())
                            {
                                _status = 0;
                                _actionStopPerformance = JFFunctions.PerformanceCounter();
                                return(false);
                            }
                            if (2 == _status)
                            {
                                _eventCmd.WaitOne();
                                if (3 == _status)
                                {
                                    _status = 0;
                                    if (InnerFlow.Stop(10) != JFWorkCmdResult.Success)
                                    {
                                        InnerFlow.Abort();
                                    }
                                    _actionStopPerformance = JFFunctions.PerformanceCounter();
                                    throw new JFBreakMethodFlowException();
                                }
                            }
                        }
                    }
                }
                else//不包含结束值
                {
                    if (_interval >= 0) //正向增加
                    {
                        for (_forValue = _startValue; _forValue < _endValue; _forValue += _interval)
                        {
                            InnerFlow.DataPool["For_Value"] = _forValue;
                            if (!InnerFlow.Action())
                            {
                                _status = 0;
                                _actionStopPerformance = JFFunctions.PerformanceCounter();
                                return(false);
                            }
                            if (2 == _status)
                            {
                                _eventCmd.WaitOne();
                                if (3 == _status)
                                {
                                    _status = 0;
                                    if (InnerFlow.Stop(10) != JFWorkCmdResult.Success)
                                    {
                                        InnerFlow.Abort();
                                    }
                                    _actionStopPerformance = JFFunctions.PerformanceCounter();
                                    throw new JFBreakMethodFlowException();
                                }
                            }
                        }
                    }

                    else //负向递减
                    {
                        for (_forValue = _startValue; _forValue > _endValue; _forValue += _interval)
                        {
                            InnerFlow.DataPool["For_Value"] = _forValue;
                            if (!InnerFlow.Action())
                            {
                                _status = 0;
                                _actionStopPerformance = JFFunctions.PerformanceCounter();
                                return(false);
                            }
                            if (2 == _status)
                            {
                                _eventCmd.WaitOne();
                                if (3 == _status)
                                {
                                    _status = 0;
                                    if (InnerFlow.Stop(10) != JFWorkCmdResult.Success)
                                    {
                                        InnerFlow.Abort();
                                    }
                                    _actionStopPerformance = JFFunctions.PerformanceCounter();
                                    throw new JFBreakMethodFlowException();
                                }
                            }
                        }
                    }
                }
            }
            catch (JFBreakMethodFlowException) //Break 正常退出循环
            {
                _status = 0;
                _actionStopPerformance = JFFunctions.PerformanceCounter();
                _actionErrorInfo       = "Success - break while";
                return(true);
            }


            _actionStopPerformance = JFFunctions.PerformanceCounter();
            return(true);
        }