stop timer before refreshing

E

Elliot

My program use a timer to 'refresh' a method "a" every several seconds,

private void a(object sender, EventArgs eArgs)
{
Timer T1 = new Timer();
T1.Interval = 100000;
T1.Start();
T1.Tick += new EventHandler(b);

Timer T2 = new Timer();
T2.Interval = 100000;
T2.Start();
T2.Tick += new EventHandler(c);
}

Inside "a", there are two timers.
My question is how can I stop timers T1 & T2 before refreshing "a" for a new
time?

Thanks for any idea.
 
I

Ignacio Machin ( .NET/ C# MVP )

My program use a timer to 'refresh' a method "a" every several seconds,

        private void a(object sender, EventArgs eArgs)
        {
                                Timer T1 = new Timer();
                                T1.Interval = 100000;
                                T1.Start();
                                T1.Tick += new EventHandler(b);

                                Timer T2 = new Timer();
                                T2.Interval = 100000;
                                T2.Start();
                                T2.Tick += new EventHandler(c);
        }

Inside "a", there are two timers.
My question is how can I stop timers T1 & T2 before refreshing "a" for a new
time?

Thanks for any idea.

You need to have a reference to them, in other words declare them at
the class level, not inside the method
but what are you trying to do? Those many timers are really necesary?
 
E

Elliot

It works. Thanks, Ignacio.


message
You need to have a reference to them, in other words declare them at
the class level, not inside the method
but what are you trying to do? Those many timers are really necesary?
 

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

Top