Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3433266
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:33:10+00:00 2026-05-18T07:33:10+00:00

I’m trying to measure the elapsed time in milliseconds between keypress events using a

  • 0

I’m trying to measure the elapsed time in milliseconds between keypress events using a dispatch timer but when declaring a dispatch timer to have an interval of 1 millisecond and then establishing the tick event it doesn’t fire every 1 millisecond but somewhere like 10-100 milliseconds (guess). How do I accurately measure time in milliseconds if this tick event doesn’t fire on time? I’m doing this in silverlight which doesn’t seem to have access to System.Timers. The same seems to happen with System.Threading.Timer.

Here’s the basics of the code:

public void StartTimer(object o, RoutedEventArgs sender)
{
    System.Windows.Threading.DispatcherTimer myDispatcherTimer = new  
    System.Windows.Threading.DispatcherTimer();
    myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 1); // 1 Milliseconds 
    myDispatcherTimer.Tick += new EventHandler(Each_Tick);
    myDispatcherTimer.Start();
}

// A variable to count with.
int i = 0;

public void Each_Tick(object o, EventArgs sender)
{
    i++;
}

public void keypress(object s, EventArgs args)
{
    label1.contents = i.ToString();
    i = 0;
}

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:33:11+00:00Added an answer on May 18, 2026 at 7:33 am

    The System.Threading timer in Silverlight is only accurate down to about 20ms. Normally you’d want a multimedia timer if you needed better resolution, but you can’t access those directly in Silverlight. That said, with some significant tweaking and tradeoffs, I’ve read that it’s possible to get a Silverlight timer that has ~3ms ms accuracy. See the docs referenced here:

    Link

    Note that I haven’t tested all those alternatives myself, but they’re worth looking into.

    Another alternative is the recently introduced System.Diagnostics.Stopwatch class. Unfortunately, this is only sometimes a high resolution timer, depending on the hardware you’re running on. And the MS docs don’t specify how they determine whether it’s truly high resolution or not, so your only option is to check the IsHighResolution property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.