Reputation: 18973
In a window service, can we have 2 timers, where one runs every 24 hours and other every 30 seconds???
The one that runs every 24 hours does one function and other sends an email every 30 seconds????
thanks!!
Upvotes: 0
Views: 1825
Reputation: 5430
That is possible, use two Timer objects from the System.Timers namespace.
You can define the interval time in milliseconds and at the interval eventhandler you can define a method to execute
Upvotes: 2
Reputation: 2417
You can have so many timers as you want. But also you can have one timer with 30 seconds period:
private int ticks = 0;
private void timerTick(...)
{
if (2880 == ticks)
{
one_void();
ticks = 0;
}
send_email();
ticks++;
}
Upvotes: 2
Reputation: 499002
Yes, this is possible.
There is no issue in having more than one timer.
Note: testing this on your own would have been faster than asking the question and waiting for an answer here.
Upvotes: 2