zoukankan      html  css  js  c++  java
  • 循环执行timer

    using System;
    using System.Collections.Generic;
    using System.Text;
    using APlusEmail.Quartz.EmailJob;
    using APlusEmail.Model;
    
    namespace APlusEmail.Quartz.Timer
    {
        public class TimerManager
        {
            System.Timers.Timer t = new System.Timers.Timer(10000); //实例化Timer类,设置间隔时间为10000毫秒; 
            public TimerManager()
            {
                t.Elapsed += new System.Timers.ElapsedEventHandler(theout);
                //到达时间的时候执行事件;   
                t.AutoReset = true;
                //设置是执行一次(false)还是一直执行(true);   
                t.Enabled = true;
                //是否执行System.Timers.Timer.Elapsed事件;    
    
            }
    
            APlusEmail.BLL.AP01SendRightEntity aP01SendRightEntityBLL = new APlusEmail.BLL.AP01SendRightEntity();
            SendEmailCeaseless sendEmailCeaselessTool = new SendEmailCeaseless();
            bool isRun = false;
            public void theout(object source, System.Timers.ElapsedEventArgs e)
            {
                //执行
                Console.WriteLine("fff");
                if (QueueManager.SendQueue.Count != 0)
                {
                    AP01SendQueueNew aP01SendQueue = QueueManager.GetQueueItem();
                    while (!isRun)//队列还有任务 同时没有任务执行
                    {
                        //根据aid获取发送任务
                        isRun = true;
                        AP01SendRightEntity aP01SendRightEntity = aP01SendRightEntityBLL.GetModel((int)aP01SendQueue.aid);
                        SendInfo sendInfo = sendEmailCeaselessTool.SendEmailLaunch(aP01SendRightEntity);
                        //根据sendinfo来判断
                        if (sendInfo.Info == "发完")
                        {
                            //删除该条queue
                            QueueManager.DeleteQueueItem();
    
                            //修改数据库
    
                            //修改xptable
    
                        }
                    }
                }
                
            }  
        }
    }
  • 相关阅读:
    javascript小测试
    js设计模式--策略模式
    js设计模式--迭代器模式
    面试题自我解析
    js设计模式--工厂模式
    js设计模式--单体模式
    Python学习一:Python简介
    Angularjs学习笔记《一》
    实现字体最小,不是默认的12px,可以在视觉上最小达到6px
    css3 transform之后,图片的清晰度下降解决方式
  • 原文地址:https://www.cnblogs.com/maijin/p/2823630.html
Copyright © 2011-2022 走看看