{
t = new System.Timers.Timer();
t.Interval = 10000;//间隔时间为15S
t.Elapsed += new System.Timers.ElapsedEventHandler(ChkSrv);//到达时间的时候执行事件;
t.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
t.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;
//t.Stop(); 停止服务
}
///
/// 定时检查,并执行方法
///
///
///
///
static object name = 0;
public void ChkSrv(object source, ElapsedEventArgs e)
{
t.Enabled = false;
t.Interval = 10000;//间隔时间为15S
lock (name)
{
name = Convert.ToInt32(name) + 1;
Thread.CurrentThread.Name = name.ToString();
}
//Console.WriteLine(DateTime.Now.ToString() + "-" + Thread.CurrentThread.Name);
//Thread.Sleep(1000000);
StatisticalData();
SetInnPointPo();//执行推送数据方法
SetInnPointApp();
t.Enabled = true;
}
执行ChkSrv()方法的时候会异常停止, IIS服务器