Global.asax定时器

2021-01-21 17:22:21 浏览数 (1)

代码语言:javascript复制
void Application_Start(object sender, EventArgs e) 
{
    //启动定时器
    System.Timers.Timer objTimer3 = new System.Timers.Timer();
    //objTimer3.Interval = 1000 * 60 * 60 * 48;//定时器 2天执行一次(两天48小时) 
    objTimer3.Interval = 1000;//定时器 1秒执行一次 
    objTimer3.Enabled = true;
    objTimer3.Elapsed  = new System.Timers.ElapsedEventHandler(insertlvsjcoinnums); 
}
代码语言:javascript复制
//跳转链接
public void requetappXml(string url)
{
    System.Net.HttpWebRequest webre = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
    webre.Method = "GET";
    webre.UserAgent = "MSIE6.0";
    System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)webre.GetResponse();
    System.IO.Stream responseStream = response.GetResponseStream();
}
代码语言:javascript复制
public void insertlvsjcoinnums(object sender, System.Timers.ElapsedEventArgs e)
{
    //跳转需要执行方法的页面
    requetappXml("http://xx.xx.cn/name/default.ashx?xmls=pc/xmls/Global.xmls");
}

0 人点赞