vs.net2008 每三分钟执行次调用一个 函数 a(string par)

解决方案 »

  1.   


    ASP.NET通过Global.asax和Timer定时器 定时调用WebService 运行后台代码 
    http://www.cnblogs.com/freeliver54/archive/2007/03/06/665625.aspx利使用global.asp定时执行ASP
    http://www.cqzol.com/programming/64495.html
      

  2.   

    在global.asax里    Private _timer As System.Timers.Timer
        Private _interval As Double = 3 * 60 * 1000    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
            ' Fires when the application is started
            Me._timer = New System.Timers.Timer( _interval)
            AddHandler _timer.Elapsed, AddressOf a        Me._timer.AutoReset = True
            Me._timer.Enabled = True
            Me._timer.Start()
        End Sub
      

  3.   

    <%@ Application Language="C#" %>
    <%@ Import Namespace="System.Timers" %><script runat="server">    void Application_Start(object sender, EventArgs e) 
        {
            // 在应用程序启动时运行的代码        Timer atimer = new Timer(10000);        atimer.Elapsed += timer_execute;        atimer.AutoReset = true;
            atimer.Enabled = true;
            
            Application.Lock();
            Application["TimeStamp"] = DateTime.Now.ToString();
            Application.UnLock();
        }    void timer_execute(object sender, EventArgs e)  //定时执行的函数
        {
            Application.Lock();
            Application["TimeStamp"] = DateTime.Now.ToString();
            Application.UnLock();
        }
                   
    </script>
      

  4.   

    很难。
    采用TIMER控件,是可以做到,但存在一个很大问题:会无故停止TIMER事件。
    以前曾经做过,再起一个监视TIMER,专用于监视另外的TIMER,使之不被停止,但仍然无法完全达到目的。你可以改用数据库的定时器,还是比较可靠的。
      

  5.   

    每三秒钟执行一次调用的源代码,<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:Timer ID="Timer2" runat="server"  Interval="3000" OnTick="Timer2_Tick">
            </asp:Timer>
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        </div>
        </form>
    </body>
    </html>
    protected void Timer2_Tick(object sender, EventArgs e)
        {
            if(Session["test"]==null||Session["test"]=="")
            {
                Session["test"]=1;
            }
            int para=(int)Session["test"];
            string strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
            strConnection += @"Data Source=" + Server.MapPath("App_Data/test.mdb");
            OleDbConnection objConnection = new OleDbConnection(strConnection);
            objConnection.Open();
            string sqlString = "Update testt Set test =" + para;
            OleDbCommand cmd = new OleDbCommand(sqlString, objConnection);
            cmd.ExecuteNonQuery();
            objConnection.Close();
            Label1.Text = "数据更新次数: " + Session["test"].ToString();
            Session["test"]=para+1;    }或者你可以搜索一下Timer的使用,楼上的资料也很详细了,呵呵 .希望可以帮到你.
      

  6.   

    呵呵 谢谢。想用global实现。
      

  7.   

    7楼 的 我会做。也做过,我想用global实现 你有方法吗,4楼的方法还行。
      

  8.   

    http://topic.csdn.net/u/20071206/10/d5a59727-d54e-4b0e-aec1-d8f209479bf4.html
    请参照这个帖子实现定时操作