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
    
                        }
                    }
                }
                
            }  
        }
    }
  • 相关阅读:
    SqlServer数据库同步方案详解(包括跨网段)
    makefile 和shell文件相互调用
    处理百万级以上的数据处理
    makefile Template(添加多个lib)
    Linux下如何删除非空目录
    makefile Template
    g++ 编译和链接
    gcc include路径
    C++ XML解析之TinyXML篇
    利用Lucene.net搭建站内搜索(2)分词技术
  • 原文地址:https://www.cnblogs.com/maijin/p/2823630.html
Copyright © 2011-2022 走看看