//传参数定时器
private static System.Timers.Timer aTimer;
Main(ApprovalID);
public static void Main(int ApprovalID)
{
aTimer = new System.Timers.Timer(600000); //10分钟 600000
aTimer.Elapsed += new ElapsedEventHandler((s, e) => OnTimedEvent(s, e, ApprovalID));
aTimer.Interval = 60000;
aTimer.Enabled = true;
aTimer.AutoReset = false;
}
private static void OnTimedEvent(object source, ElapsedEventArgs e, int ApprovalID)
{
//解锁申请表
Model.Sys.ShenPiApprovalModel SQM = new ShenPiApprovalModel();
SQM = BLL.Sys.ShenPiApprovalBLL.Instance.GetModel(ApprovalID);
if (SQM.ApprovalState != 1)
{
SQM.ApprovalState = 0;//锁定申请表
BLL.Sys.ShenPiApprovalBLL.Instance.UpdateJS(0, " ID=" + ApprovalID + " ");
}
}
二、
//不传参数 定时器
System.Timers.Timer t = new System.Timers.Timer(60000);//实例化Timer类,设置间隔时间为10000毫秒;
t.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件;
t.AutoReset = false;//设置是执行一次(false)还是一直执行(true);
t.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;
//定时器函数
public void theout(object source, System.Timers.ElapsedEventArgs e)
{
Model.User.UserModel userM = new Model.User.UserModel();
var MM = BLL.User.UserBLL.Instance.GetModel(6326);
MM.LinkMan = "定时器我是";
BLL.User.UserBLL.Instance.Update(MM);
}