System.Timers.Timer - use Start/Stop or Enabled?

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

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
 
If you ever want to know what's really going on inside of some .NET framework
property or method, I highly recommend Lutz Roeder's .NET Reflector. It will
disassemble any .NET code back into VB.NET or C#.

Using it on Timer.Start show that all Timer.Start is doing is:

Public Sub Start()
Me.Enabled = True
End Sub

So there's no difference in calling Start or just setting Enabled=True.
They do exactly the same thing.
 
well i guess that this is another Backwards compatibility issue ,,,,, i.ow.
just implemented to keep it simple for programmers from previous versions of
visual basic
( i am one of them ,,,,, however i try to use the new ones , as i noticed
that they are also often used in C# , and sometimes i ride this crocodile
)
 
The Timer is a .NET Framework control, not a VB.NET control, so I don't know
that backward compatibility was the driving concern. There's a school of
thought that says that setting a property shouldn't have side effects, and
setting Enabled to true does (it causes events to start firing). To me, it's
more logical to call Start and Stop. The question is, how do you know if the
timer is already running? You look at the Enabled property. However,
Enabled isn't read-only, so you can use it to start the timer if you so
desire.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top