Esempio n. 1
0
        // 线程名/流程名/设备ID, 忽略返回值

        protected int do_New(clsFaim3 v_faim3, DAL_CommData v_dao_comm, string vflowName)
        {
            _faim3    = v_faim3;
            _dao_comm = v_dao_comm;
            // 无流程名, 则取类名
            _flowName = (string.IsNullOrEmpty(vflowName)) ? this.GetType().Name : vflowName;
            #region                                         // dict_Threads 线程池

            if (_faim3.dict_Threads.ContainsKey(_flowName)) // 存在key
            {
                FACC.F_Log.Debug_1("do_New()", string.Format("--->>>> {0}流程/设备存在", _flowName));
                return(-1);                  //
            }
            clsThread _en = new clsThread(); // 线程消息
            _en.Info          = new clsThreadInfo();
            _en.Name          = _flowName;
            _en.Info.flowName = _flowName;
            // 专用线程代理   dict_Threads.Add
            _en.Del = new System.Threading.ThreadStart(do_Sub_While); // 实例化代理

            _faim3.dict_Threads.Add(_flowName, _en);
            #endregion
            F_Log.Debug_1("do_New()", string.Format("初始化 流程:{0}", _flowName));
            return(0);
        }
Esempio n. 2
0
        // 开 指定的业务

        public void doStartTh(string vflowName)
        {
            if (string.IsNullOrEmpty(vflowName))
            {
                return;
            }
            if (!_faim3.dict_Threads.ContainsKey(vflowName))
            {
                FACC.F_Log.Debug_1("clsThManagerBLL", string.Format("--->>>>! 线程没有启动 1:{0}", vflowName));
                return;
            }
            clsThread _info = _faim3.dict_Threads[vflowName];

            if (_info.th != null)// 原有流程
            {
                FACC.F_Log.Debug_1("clsThManagerBLL", string.Format("准备 清除原有 流程:{0}", vflowName));
                _info.th = _info.th;
                if ((_info.th != null) &&
                    (_info.th.ThreadState != ThreadState.Aborted) &&
                    (_info.th.ThreadState != ThreadState.Stopped)) // :已启动, 停止
                {
                    FACC.F_Log.Debug_1("clsThManagerBLL", string.Format("停止 运行原有 流程:{0}", _info.th.Name));
                    _info.th.Abort();
                    _info.Info.cnt_heart = -1;
                    Thread.Sleep(10);
                }
                _info.th = null;
                // 清除
                FACC.F_Log.Debug_1("clsThManagerBLL", string.Format("完成 清除原有 流程:{0}", vflowName));
            }
            if (_info.Del != null) // 原有代理
            {
                FACC.F_Log.Debug_1("clsThManagerBLL", string.Format("存在代理,绑定:{0}", vflowName));
                _info.th = new Thread(_info.Del);  // 用方法名指定代理
                _info.Info.allowWhile = eSwitch.On;
                FACC.F_Log.Debug_1("clsThManagerBLL", string.Format("启动 流程-->流程池:{0}", vflowName));
                _info.th.Start();
            }
            else
            {
                FACC.F_Log.Debug_1("clsThManagerBLL", string.Format("--->>>> 不存在 代理 :{0}", vflowName));
            }
        }
Esempio n. 3
0
        // 执行 指定的流程

        public void doRunFlow(string vflowName = "DAL_Buttons", int runMode = 3)
        {
            if (string.IsNullOrEmpty(vflowName))
            {
                return;
            }
            if (!_faim3.dict_Threads.ContainsKey(vflowName))
            {
                return;
            }
            clsThread _info = _faim3.dict_Threads[vflowName];

            if (_info.th == null ||
                _info.th.ThreadState == System.Threading.ThreadState.Aborted ||
                _info.th.ThreadState == System.Threading.ThreadState.Stopped) // :已启动, 停止 未开启流程
            {
                doStartTh(vflowName);
                System.Threading.Thread.Sleep(100);
            }
            doRunMode(vflowName, runMode);
        }