Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

Timer Enabled, Start, Stop

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
srcalc
Asked:
srcalc
  • 3
  • 2
2 Solutions
 
drichardsCommented:
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
 
srcalcAuthor Commented:
They are 100% exactly the same?
0
 
DJ_Back-QCommented:
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
Independent Software Vendors: 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!

 
srcalcAuthor Commented:
Ok thanks!
0
 
drichardsCommented:
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
 
srcalcAuthor Commented:
Thanks for the clarification
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now