By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,894 Members | 1,191 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,894 IT Pros & Developers. It's quick & easy.

stop timer before refreshing

P: n/a
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.

Jun 30 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Jun 30, 3:54*pm, "Elliot" <elliot_barc...@hotmail.co.ukwrote:
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?
Jun 30 '08 #2

P: n/a
It works. Thanks, Ignacio.
"Ignacio Machin ( .NET/ C# MVP )" <ig************@gmail.comwrote in
message
news:d2**********************************@a70g2000 hsh.googlegroups.com...
On Jun 30, 3:54 pm, "Elliot" <elliot_barc...@hotmail.co.ukwrote:
>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?
Jun 30 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.