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

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

 更新時(shí)間:2013年04月25日 11:59:23   作者:  
全局定時(shí)定期執(zhí)行某些操作看起來是多么自動(dòng)化的一個(gè)問題不過在.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)用程序啟動(dòng)時(shí)運(yùn)行的代碼
System.Timers.Timer myTimer = new System.Timers.Timer(60000); // 每個(gè)一分鐘判斷一下
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)閉時(shí)運(yùn)行的代碼
}
void Application_Error(object sender, EventArgs e)
{
//在出現(xiàn)未處理的錯(cuò)誤時(shí)運(yùn)行的代碼
}
void Session_Start(object sender, EventArgs e)
{
//在新會(huì)話啟動(dòng)時(shí)運(yùn)行的代碼
}
void Session_End(object sender, EventArgs e)
{
//在會(huì)話結(jié)束時(shí)運(yùn)行的代碼。
// 注意: 只有在 Web.config 文件中的 sessionstate 模式設(shè)置為
// InProc 時(shí),才會(huì)引發(fā) Session_End 事件。如果會(huì)話模式
//設(shè)置為 StateServer 或 SQLServer,則不會(huì)引發(fā)該事件。
}
private static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
{
//需要的操作寫在這個(gè)方法中
}

相關(guān)文章

最新評(píng)論