面对计时器的问题

面对计时器的问题

问题描述:

我有一个asp页面,我在其中编写C#代码,用于从一个表中获取数据并更新另一个表。



现在我想连续检查一个级别在第一级,如果到达throuseld然后我想更新另一个表



所以我使用ajax定时器控件



给出了代码

I have an asp page in which I write C# code for taking data from one table and update the another table.

Now I want to continuously check one level in first level if reaches to throuseld then I want to update another table

So I use ajax timer control

the code is given

<asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="10000" >
  <!--we have to put 24*60*60*1000=86400000 milli-seconds for one day-->
</asp:Timer>

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager></pre>



i已经写了c#代码用于更新计时器滴答事件中的数据库我正在工作okk



现在如果用户从这个页面转移到另一个页面而不是计时器将无法工作,数据库将无法更新



该怎么办?我不想使用任何状态管理技术



请给我最简单的解决方案


i have write c# code for updating database in timer tick event i is working okk

now if a user transfer from this page to another page than the timer will not work and database will not update

what to do? i dont want to use any state management technique

pls give me easiest solution on this

使用System.Windows.Threading namespace中存在的DispatcherTimer类。示例代码

use DispatcherTimer class which is present in System.Windows.Threading namespace.Sample code
DispatcherTimer t=new DispatcherTimer();
//t.Interval=new Timespan(Hours,Minutes,Seconds);
//Suppose you want to set for a day then write
t.Interval=new Timespan(24,0,0);
t.Start();