The simplest way to implement this is to use a timer control in you service; so that you can do some work on the timer tick for each time.
Declare following member vaiables at top.
private System.Timers.Timer ProcessTimer;
private TimeSpan PollInterval = TimeSpan.FromMinutes(1);
private DateTime PollTimerStopTime = DateTime.MaxValue;
On the
OnStart
event of the service initialize you timer like following.
protected override void OnStart(string[] args)
{
this.ProcessTimer = new System.Timers.Timer();
this.ProcessTimer.Interval = this.PollInterval.TotalMilliseconds;
this.ProcessTimer.AutoReset = false;
this.ProcessTimer.Elapsed += new System.Timers.ElapsedEventHandler(ProcessTimer_Elapsed);
this.PollTimerStopTime = DateTime.MaxValue;
this.ProcessTimer.Start();
}
Handle the ProcessTimer_Elapsed
private void ProcessTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (e.SignalTime < this.PollTimerStopTime)
{
}
}
You can find samples on this on google.