Click here to Skip to main content
15,921,279 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to query a table for 60 secs in windows service??I have created the service..can some one help me as I'm new to this??
Posted
Comments
Sebastian T Xavier 30-Mar-12 3:15am    
can you make it more clear?
sindhuan 30-Mar-12 3:31am    
I have created the service project.In the project i should code it in such a way it should fetch the records form the table x for every 60 secs.
Herman<T>.Instance 30-Mar-12 3:34am    
use Timer object
Herman<T>.Instance 30-Mar-12 3:33am    
http://www.w3schools.com/sql/default.asp

Use Timer class and ElapsedEventHandler delegate.
The sample code looks like below

C#
double timeout = 900000;
if (time != null && time.Length > 0)
    timeout  = Convert.ToInt64(time);
System.Timers.Timer timer =  new System.Timers.Timer();
timer.Interval = timeout;
timer.AutoReset = true;
timer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimeReached);
timer.Start();


Please change the timeout value accoring to ur convenience.It is in second.
 
Share this answer
 
v2

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