How to create a loop in a Windows NT Service

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey guys,

I've written several NT services before using Delphi. When I did, I
would typically use the timer component and have a particular procedure run
every, say... 30 minutes. What would the code (in C#) look like in order to
create a loop under the Service1 procedure that would run every 30 minutes?
Right now, just for testing, I have it run initially in the service start,
but after that, it doesn't run again.

Any help is appreciated....

Oh, I'm using C# in VS2005 with the Service Template.



Thanks!!!

Todd
 
What would the code (in C#) look like in order to
create a loop under the Service1 procedure that would run every 30 minutes?

Check out the System.Timers.Timer class.


Mattias
 
At a Timer class in the OnStart() method of the Windows Service. Enable the
timer and set its interval. Also add an event handler for its elapsed event.
Call the start method of the timer.

Do what you want in the elapsed event. This is your "loop"

Stop the timer in the OnStop method of the WS.

Good luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top