|
-
Feb 21st, 2008, 11:46 PM
#1
Thread Starter
PowerPoster
[2.0] Start a service at a predefined time.
Hi all,
I wrote a C# .Net service to automatically do some process in each 10 seconds. Say I start the service at 10:10:10 hours, then process are executed at 10:10:10, 10:10:20, 10:10:30 ......and so on until I stop the service.
But I want to start the service at 10 seconds interval. That is either on 00, 10, 20, 30... seconds time. Not like 11, 34, 56....
In other words, even I start the service manually at anytime my processing should start like times on 10:20:00, 2:45:30, 11:19:50, etc
I think it is clear for you now.
All the things I start from the constructor method. May following code segment helps you...
Code:
namespace RfService
{
public class RfService : System.ServiceProcess.ServiceBase
{
public RfService()
{
InitializeComponent();
const double INTERVAL = 10000;
TimerTicker = new System.Timers.Timer( INTERVAL );
TimerTicker.Elapsed += new ElapsedEventHandler( this.ServiceTimer_Tick );
}
private void ServiceTimer_Tick( object sender, System.Timers.ElapsedEventArgs e )
{
// Do the processing here
}
}
}
Can you guys and gals give me a help to do it.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|