I've written a application and using 6 timers that must start after each other but these timers don't work properly. I don't know much about timers.
For example, timer1 start and something happen in application. then timer1 must stop forever and timer2 must start immediately and something happen in application. Then timer2 must stop forever and timer3 must start and so on.
Please help.
Here is my code:
int yyyy = 0;
void move()
{
yyyy++;
if (yyyy <= 1)
{
timer1.Start();
timer1.Interval = 15;
timer1.Tick += new EventHandler(timer_Tick1);
}
if (yyyy <= 2)
{
timer2.Start();
timer2.Interval = 15;
timer2.Tick += new EventHandler(timer_Tick2);
}
if (yyyy <= 3)
{
timer3.Start();
timer3.Interval = 15;
timer3.Tick += new EventHandler(timer_Tick3);
}
if (yyyy <= 4)
{
timer4.Start();
timer4.Interval = 15;
timer4.Tick += new EventHandler(timer_Tick4);
}
if (yyyy <= 5)
{
timer5.Start();
timer5.Interval = 15;
timer5.Tick += new EventHandler(timer_Tick5);
}
if (yyyy <= 6)
{
timer6.Start();
timer6.Interval = 15;
timer6.Tick += new EventHandler(timer_Tick6);
}
}
and: (for timer2 for example).
( all timers have exactly same below code).
int t = 0;
private void timer_Tick2(object sender, EventArgs e)
{
t++;
if (t <= 150)
{
// do somthing
}
else
timer2.Stop();
}
yyyy? where are you re-callingmove? and finally, why use 6 different timers, you can use a single timer and handle the different code blocks in a single callback using aswitch?yyyyis (for example) 1 then all of those timers will start, right?