Web定时执行某个方法-网页获取
2013-08-24 08:45
225 查看
实现该功能用到的是System.Timers.Timer
将定时的方法添加到Global.ascx.cs中
将定时的方法添加到Global.ascx.cs中
public class Global : System.Web.HttpApplication { protected void Application_Start(object sender, EventArgs e) { //在应用程序启动时运行的代码 System.Timers.Timer myTimer = new System.Timers.Timer(60000); // 每个一分钟判断一下,单位为毫秒 myTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent); //执行需要操作的代码,OnTimedEvent是要执行的方法名称 myTimer.Interval = AutoUpdateGoldPriceTime; myTimer.Enabled = true; } } protected void Session_Start(object sender, EventArgs e) { } protected void Application_BeginRequest(object sender, EventArgs e) { } protected void Application_AuthenticateRequest(object sender, EventArgs e) { } protected void Application_Error(object sender, EventArgs e) { } protected void Session_End(object sender, EventArgs e) { } protected void Application_End(object sender, EventArgs e) { } protected void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e) { //需要定时执行的逻辑 }
相关文章推荐
- 给web网页加上生成时间,并在页面方法执行或者控件方法执行中查找性能瓶颈
- android webview获取网页源代码,js执行前后
- 给web网页加上生成时间,并在页面方法执行或者控件方法执行中查找性能瓶颈
- Android中WebView获取网页中标题 ,内容, 图片的方法
- 如何使用Linux的Crontab定时执行PHP脚本的方法
- js代码定时执行一个方法,延迟一定时间后执行一个函数
- [Oracle]获取执行计划的各个方法总结
- 安卓加载webView只显示部分网页的方法
- JavaScript获取网页中HTML元素的几种方法分析
- 提高Web 2.0网页执行效能的三个有效招
- Android 浏览网页:WebView 嵌入浏览器(浏览历史返回、自定义加载失败界面、支持缩放、获取标题栏)
- oracle获取sql执行计划方法
- Android: 在WebView中获取网页源码
- Web中实现网页跳转的方法大总结:
- Unity3D教程:如何获取某个方法执行的时间
- Android开发中使用WebView控件显示找不到网页的解决方法
- shell脚本直接执行没有问题,crontab定时执行失败的解决方法
- 解决Spring定时计划任务重复执行两次或多次(实例被构造两次)问题的方法
- Android-WebView网页访问方法
- asp.net 利用HttpWebRequest自动获取网页编码并获取网页源代码