ASP.NET如何定时调用一个函数

①首先,在WebSite里追加一个Gobal Application Class。
<%@ Application Language="C#" %>

<script runat="server">
   
void Application_Start(object sender, EventArgs e)
    {
       
// Code that runs on application startup
        System.Timers.Timer timer = new System.Timers.Timer();
        timer.AutoReset
= false;
       
// 定时一分钟
        timer.Interval = 60000;
        timer.Elapsed
+= new System.Timers.ElapsedEventHandler(timer_Elapsed);
        timer.Start();
    }

   
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
    {
       
// 在这里调用你想调用的方法。
    }
</script>
posted @ 2008-05-16 13:33  西门啥都吹  阅读(797)  评论(1编辑  收藏  举报