Пример #1
0
        /// <summary>
        /// 检查是否要运行(每隔一段时间执行)
        /// </summary>
        /// <returns></returns>
        public ServicesMessage CheckRun()
        {
            ServicesMessage ret = null;

            if (Tick)
            {
                ret = new ServicesMessage(this);
                if (!DoAction(ret))
                {
                    ret = null;
                }
                _lasRun = DateTime.Now;
            }
            return(ret);
        }
Пример #2
0
        /// <summary>
        /// 运行自动服务
        /// </summary>
        public List <ServicesMessage> DoTick()
        {
            List <ServicesMessage> lstMessage = new List <ServicesMessage>(_dicServices.Count);

            foreach (KeyValuePair <string, AbsServicesHandle> kvp in _dicServices)
            {
                try
                {
                    ServicesMessage mess = kvp.Value.CheckRun();
                    if (mess != null)
                    {
                        lstMessage.Add(mess);
                    }
                }
                catch (Exception ex)
                {
                    if (OnThrowException != null)
                    {
                        OnThrowException(kvp.Value, ex);
                    }
                }
            }
            return(lstMessage);
        }
Пример #3
0
 /// <summary>
 /// 执行方法
 /// </summary>
 protected abstract bool DoAction(ServicesMessage message);