zoukankan
html css js c++ java
在B/S系统中引入定时器的功能
现在在ASP。NET中可以使用自定义实现IHttpModule接口的类来加载一个定时器。
public
class
OilIHttpModule : IHttpModule
{
public
static
Timer analyseTimer;
//
分析数据的定时器 static int intLastTrialInfo_id;
//
最后分析的ID static long intAnalyseInterval= 10000;
//
间隔的时间 public OilIHttpModule() { } public String ModuleName { get { return "OilModule"; } }
//
/初始化模型 public void Init(HttpApplication application) { application.BeginRequest += (new EventHandler(this.Application_BeginRequest));
//
增加处理请求时触发的事件 if(intLastTrialInfo_id==0) {
//
获取最后分析的 trialInfo_id intLastTrialInfo_id = globalMethod.getLastAnalyseTrialInfo_id(); }
//
判断Timer是否存在,如果没有则实例化 if(analyseTimer==null) analyseTimer = new Timer(new TimerCallback(analyseData),null,intAnalyseInterval,intAnalyseInterval); }
private
void
Application_BeginRequest(Object source, EventArgs e)
{
//
null
//
HttpApplication application = (HttpApplication)source;
//
application.Response.Write(intLastTrialInfo_id.ToString()); }
//
/要定时执行的程序片段 private void analyseData(object obj) {
//
/很重要,可以防止定时器被重新生成 analyseTimer.Change( System.Threading.Timeout.Infinite, intAnalyseInterval );
//
StatsInterval int intTrialInfo_idAfterUpdate; intTrialInfo_idAfterUpdate = globalMethod.AnalyseTrialFromTrialInfo_id(intLastTrialInfo_id); if(intTrialInfo_idAfterUpdate > intLastTrialInfo_id) { intLastTrialInfo_id = intTrialInfo_idAfterUpdate; } } public void Dispose() { analyseTimer = null;
}
查看全文
相关阅读:
CF566E Restoring Map
CF1034D Intervals of Intervals
CF1285F Classical?
Java日报
课程考核感想
每日日报8月31日
每日日报8月30日
每日日报8月29日
每日日报8月28日
每日日报8月27日
原文地址:https://www.cnblogs.com/ghd258/p/264072.html
最新文章
AT2390 [AGC016F] Games on DAG
AT5202 [AGC038E] Gachapon
AT5141 [AGC035D] Add and Remove
CF505E Mr. Kitayuta vs. Bamboos
AT2534 港湾設備 (Port Facility)
CF1172F Nauuo and Bug
CF464D World of Darkraft
AT2384 [AGC015F] Kenus the Ancient Greek
【2020.9.12 NOIP模拟赛 T3】普及组
提高组(计数)
热门文章
长链剖分学习笔记
线性代数
世界第一的猛汉王
AGC018E Sightseeing Plan
【2020.9.3 NOIP模拟赛 T1】排列
组合数学(含二项式反演,特殊数列,置换群)
容斥(含min-max容斥)
HEAT OJ #39. 【2020.9.3 NOIP模拟赛 T3】C
Color a Tree & 排列
#575. 「LibreOJ NOI Round #2」不等关系
Copyright © 2011-2022 走看看