Hello,
I am developing a windows service in VS 2005 that will monitor time and do something every 5 seconds.
I have created some code using the stopwatch class. Can anyone tell me if this is the best way to do this .
Many thanks in advance,Code:protected override void OnStart(string[] args) { // TODO: Add code here to start your service. sw.Start(); this.RunningTime(); } protected override void OnStop() { // TODO: Add code here to perform any tear-down necessary to stop your service. sw.Stop(); } private void RunningTime() { if (sw.IsRunning) { if (sw.Elapsed.Seconds == 5) { //Do something here } } }
Steve




Reply With Quote