Click here to Skip to main content
15,908,254 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
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
XML
<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 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
Posted
Updated 31-Dec-13 8:45am
v2
Comments
ZurdoDev 31-Dec-13 8:56am    
There is no "easiest" solution for this. If you need it to keep firing over and over after they leave the page then use a windows service or a scheduled task. If you only care about it firing once and if they leave the page it can finish then you can use jquery.ajax to call a webservice and it will keep running after they leave the page.
Rana Zarour 31-Dec-13 8:59am    
am not sure about that but have you tried to add timer in master page and remaining time in session ??
CHill60 31-Dec-13 9:09am    
Why not check the threshold before updating the table?
JoCodes 31-Dec-13 12:11pm    
For periodic updates you can use a windows service scheduled which calls webservice implemented for updates.
Charan_Kumar 6-Jan-14 5:03am    
during page load of the page enable timer event...

1 solution

use DispatcherTimer class which is present in System.Windows.Threading namespace.Sample code
C#
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();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900