欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

.net全局定時定期執(zhí)行某些操作在Global.asax中具體實(shí)現(xiàn)

 更新時間:2013年04月25日 11:59:23   作者:  
全局定時定期執(zhí)行某些操作看起來是多么自動化的一個問題不過在.net的Global.asax文件中稍微配置即可實(shí)現(xiàn),詳細(xì)配置如下,感興趣的朋友可以參考下哈
復(fù)制代碼 代碼如下:

<%@ Application Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.Collections" %>
<%@ Import Namespace="System.IO" %>
//引入類庫
<script runat="server">
//add by chairuirui 2013-3-26
void Application_Start(object sender, EventArgs e)
{
//在應(yīng)用程序啟動時運(yùn)行的代碼
System.Timers.Timer myTimer = new System.Timers.Timer(60000); // 每個一分鐘判斷一下
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent); //執(zhí)行需要操作的代碼,OnTimedEvent是要執(zhí)行的方法名稱
myTimer.Interval = 60000;
myTimer.Enabled = true;
}
void Application_End(object sender, EventArgs e)
{
//在應(yīng)用程序關(guān)閉時運(yùn)行的代碼
}
void Application_Error(object sender, EventArgs e)
{
//在出現(xiàn)未處理的錯誤時運(yùn)行的代碼
}
void Session_Start(object sender, EventArgs e)
{
//在新會話啟動時運(yùn)行的代碼
}
void Session_End(object sender, EventArgs e)
{
//在會話結(jié)束時運(yùn)行的代碼。
// 注意: 只有在 Web.config 文件中的 sessionstate 模式設(shè)置為
// InProc 時,才會引發(fā) Session_End 事件。如果會話模式
//設(shè)置為 StateServer 或 SQLServer,則不會引發(fā)該事件。
}
private static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
{
//需要的操作寫在這個方法中
}

相關(guān)文章

最新評論