Am I doing timer correctly? When I click Start, Milliseconds seems not run as fast. It runs like 1, 15, 35, 65 ,etc. It does not start from 1, 2, 3 (real fast here)
 DispatcherTimer tmr = new DispatcherTimer();
        System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

            tmr.Interval = TimeSpan.FromSeconds(1);
            tmr.Tick += onTimerTick;

void onTimerTick(object sender, EventArgs args)
            textBox1.Text = string.Format("{0:D2}:{1:D2}:{2:D2}:{3:D3}",

        private void button2_Click(object sender, RoutedEventArgs e)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
You don't understand.
A timer does NOT guarantee to fire at a precise interval, that is a MINIMUM time between the events.  There is also a system minimum which is about 16ms (at least it used to be that some years ago) so it is behaving perfectly correctly.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Typically anything less than 50 ms in .Net is going to cause problems...

What is the "big picture" here?
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:

Please refer to following links hope they will be helpful to get precise timer

AndyAinscowFreelance programmer / ConsultantCommented:
Just one point to make certain you understand.
The values returned from the stopwatch (elapsed property) should be accurate to milliseconds - for normal usage a timer as you are using it is also good enough.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.