Solved

Timer Enabled, Start, Stop

Posted on 2004-08-13
6
365 Views
Last Modified: 2012-06-27
Can someone explain or link to an explaination of the difference between the Timer Enabled property and the Start, Stop methods? Ex: Aren't Timer.Enabled = False and Timer.Stop the same thing?
0
Comment
Question by:srcalc
  • 3
  • 2
6 Comments
 
LVL 19

Assisted Solution

by:drichards
drichards earned 40 total points
ID: 11794338
They are the same.  Here's what the doc says:

"Setting Enabled to true is the same as calling Start, while setting Enabled to false is the same as calling Stop."
0
 
LVL 4

Author Comment

by:srcalc
ID: 11794359
They are 100% exactly the same?
0
 
LVL 3

Accepted Solution

by:
DJ_Back-Q earned 60 total points
ID: 11794389
Start will of course start the timer, and Stop will of course delete the timer.

If you set Timer.Enabled = True it will start the timer. The Timer.Start() basically enables the timer in the background.

If you set Timer.Disabled = True it will stop the timer but the one difference is that a Timer that has been disabled is subject to garbage collection. That means a timer that is disable can be destroyed.

I suggest that you always use Start and Stop
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:srcalc
ID: 11794408
Ok thanks!
0
 
LVL 19

Expert Comment

by:drichards
ID: 11794510
Actually, it appears to depend on what type of timer you mean.

System.Timers.Timer:
  Stop/Start and Enabled true/false are identical

System.Windows.Forms.Timer
  DJ_Back-Q's comments are true except that there is no Disabled.  It's Enabled = false.

System.Threading.Timer
  Doesn't use Enabled or Start/Stop - uses Change instead.
0
 
LVL 4

Author Comment

by:srcalc
ID: 11794542
Thanks for the clarification
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question