protected void Application_Start(object sender, EventArgs e) { //新建计时器 System.Timers.Timer myTimer = new System.Timers.Timer(1000); myTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);//调用方法 myTimer.Inte
protected void Application_Start(object sender, EventArgs e) { //新建计时器 System.Timers.Timer myTimer = new System.Timers.Timer(1000); myTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);//调用方法 myTimer.Interval = 1000; //每秒跑数据 myTimer.Enabled = true; DbInitialize.Initialize(); } private void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e) { // 得到 hour minute second 如果等于某个值就开始执行某个程序。 int intHour = e.SignalTime.Hour; int intMinute = e.SignalTime.Minute; int intSecond = e.SignalTime.Second; // 定制时间; 比如 在23:59 :59 的时候执行方法 int iHour = 23; int iMinute = 59; int iSecond = 59; if (intHour == iHour && intMinute == iMinute && intSecond == iSecond) { //执行调用方法 iss.GetBase(); } }