每五分钟执行一次方法 [英] Execute method every five minutes

查看:212
本文介绍了每五分钟执行一次方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上有两个页面.用户只能看到第一页.用户无权访问第二页.从不加载第二页.
但是我在第二页上有一个名为Add()的方法,该方法位于一个名为myfolder的文件夹中.如何每五分钟实施一次此方法.
我使用了以下代码,但是有问题.
在页面加载状态下执行该方法.如果关闭此页面,请勿一次调用此方法.在运行ASP.NET时,我并没有停止在ASP.NET中,只是关闭了浏览器屏幕.

我想要的是,即使用户没有打开页面,该方法也将在白天自动应用

There are two pages on my website. Only the first page the user sees. User does not have access to the second page.The second page is never loaded.
But i have on the second page method called Add(), this method is in a folder called myfolder. How do I implement this method every five minutes.
I''ve used the following code but there is a problem.
Method is executed when the page is loaded condition. If you close this page, do not call this method at a time. While ASP.NET is running on, I did not stop in ASP.NET, I just close the browser screen.

What I want is that the method will automatically be applied during the day, even when the user does not open the page

<asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="300000" />

        <asp:UpdatePanel ID="UpdatePanell" runat="server" UpdateMode="Always">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1"  EventName="Tick" />
        </Triggers>





protected void Timer1_Tick(object sender, EventArgs e)
       {
           myclass a=new myclass;
           a.Add();
       }

推荐答案

参考:

http://stackoverflow.com/questions/4409558/c-sharp-timer-每5分钟运行一次 [ ^ ]
Refer:

http://stackoverflow.com/questions/4409558/c-sharp-timer-run-every-5th-minute[^]


这篇关于每五分钟执行一次方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆