How can I set my timer to work with seconds? When I use the timer from toolbox, without any changes it starts working with another time unit.
I will be grateful for any help which you can give me.
I have something like this:
t = 0;
timer1.Start();
if (t == 600)
timer1.Stop();
EDIT
Use timer.interval = 1000 * n; where n is the number of seconds between the ticks.
Timer.Interval property takes the value in milliseconds. You should multiply your valued to 1000 to set the interval to seconds.
aTimer.Interval = 1*1000; // 1 second interval
aTimer.Interval = 2*1000; // 2 seconds interval
Edit:
If I understood correctly, you should register Timer.Tick event like
aTimer.Tick += new EventHandler(TimerEventProcessor);
and check the value of t in its event handler. If t == 600 then you can stop the timer
private static void TimerEventProcessor(Object myObject, EventArgs myEventArgs)
{
...
t++;
if(t == 600)
aTimer.Stop();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With