473,486 Members | 2,424 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

stop timer before refreshing

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
2 1534
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
11079
by: Geoff | last post by:
Hey.. I'm having problems with stopping this timer from outside the 'runTimer()' class.. i have no problems calling 'cancel()' from inside the run() method but I want to be able to stop the Timer...
18
2165
by: Joe | last post by:
Hi, I am trying to alter the refresh rate of an online webpage in a webbrowser control using MFC. However the Timer ID is stored in a local variable and I don't know how to access it. Is there a...
8
2765
by: Daniel P. | last post by:
I'm trying to set a timer that gets called every 3 seconds so I can update a field in the UI with the time elapsed since the process started. What am I doing wrong that timerDF_Tick does not get...
7
2660
by: Mike Eaton | last post by:
Hi All, I have a simple application that allows users to clock in and out and stores the data for use by the payroll department. It spends most of its life as a tray icon and when the user...
6
3299
by: Xero | last post by:
Hi. I have created a 'stop watch' program. The working principle of the program is to declare an integer (say 'intTime'), which is initalized to zero. Once the user clicks the 'Start' button,...
3
26025
by: Tom | last post by:
When using system.timers.timer, which should one use to start/stop the timer? Start/Stop, or Enabled=True/False? If what I read is true, both really do the same thing, so I don't know if there is...
4
1855
by: Philip Wagenaar | last post by:
I have a Queue that contains filenames. I have a System.Timer with it's interval set to 200. I load the Queue up with 35.000 files. I start the Timer. On Timer.Elapsed I take a file from the...
4
1899
by: Boki | last post by:
Hi All, I have a timer, if my data queue Q has data, the timer should start work, if there is no data in Q, the timer should stop. However, there is an event can fire timer to start. Should I...
7
8617
by: Daniele Piccinini | last post by:
Hallo, I've writed a C# windows service in VS 2003. This service use a System.Timers.Timer to periodically call some functions of a web service. ( Some of this functions required minutes to be...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7126
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.