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 } } } } } }