473,549 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
+ 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 1542
On Jun 30, 3:54*pm, "Elliot" <elliot_barc... @hotmail.co.ukw rote:
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******** *************** ***********@a70 g2000hsh.google groups.com...
On Jun 30, 3:54 pm, "Elliot" <elliot_barc... @hotmail.co.ukw rote:
>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
11093
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 when I press a button (stopTimer()). With the code I've got here, i get an error saying 'void cannot be dereferenced' ... has anyone got any ideas...
18
2176
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 technique in Javascript that I might be able to use/adapt? I have a timer set within a prototype thus: ;HControl.prototype.setFLTimeout =...
8
2768
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 called? private System.Windows.Forms.Timer timerDF; this.timerDF = new System.Windows.Forms.Timer(this.components);
7
2663
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 clicks on it, a clock-in/out form is displayed. My problem is this: I've added a timer to the main module to allow the user to set a time to be...
6
3316
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, the Timer component (the one found at System.Windows.Forms.Timer) starts ticking (with this code: Timer.Enabled = True). Whenever the timer ticks,...
3
26040
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 an advantage to using one over the other. Just curious... Thanks in advance. Tom
4
1858
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 Queue (.dequeue) and do my business logic on it. I use a Windows Forms to control all this. Start button to start the timer and a Stop button to...
4
1912
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 add a variable to know how many records inside Q ? Ya, I think so, because timer should use for unknown events, check it in a period.
7
8634
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 executed ). The timer interval is 1 sec, and each functions 'counts' his number of timer clock to know when it must be executed. Sometimes happen...
0
7526
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7457
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7723
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7965
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7483
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7817
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5092
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
771
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.