Timer Precision

Hi,

I am implementing an app that needs to send out data at 20ms intervals. I have tried 2 timers,

System.Timers.Timer and System.Windows.Forms.Timer. Neither seems very steady at that rate.

Is the one that is, maybe that is too precise

Any suggestions

Thanks

Jeff



Answer this question

Timer Precision

  • Walter R

    dear sir or madame ,

    i need another timer which is a timertick but is according to microseconds,can you help me

    it's very essential.please reply!



  • NetPochi

    Hi,

    That is one of the things that I have tried but at 20ms the timer is very erratic.

    Jeff


  • Prudhvidhar

    dear sir or madame,

    i need a timertick which repeat my process every 400 micro seconds.

    can you help me

    i don't have enough time to find it.

    please help me as soon as possible.

    thanks.



  • Node_Pointer

    Hooper,
    according to MSDN, the actual resolution of System.Windows.Forms.Timer is 55msec. To make things worse, the event is actually sent through the message queue as a WM_TIMER, which means that if your form is busy the event might be delayed.

    System.Timers.Timer is marginally better. A small test program I wrote seems to indicate a resolution in the range of 15ms, and some fluctuations, which is still not good for your purposes... your mileage might vary, I'm just reporting what I got on my test PC.

    A possible solution is to use a Multimedia timer, as described here.

    HTH
    --mc


  • UnKnown Nick

    Hi,

    I have downloaded DirectX and I think I am going to try that.

    Thanks

    Jeff


  • AWolf

    According to this tutorial http://msdn.microsoft.com/coding4fun/gamedevelopment/beginning/default.aspx

    there is a timer that has a precision of 1 microsecond

    "QueryPerformanceCounter: This is the preferred timer to use; it has a resolution of less than 1 microsecond. This is the timer most often used in game development."

    I don't know how to use it, but its a timer..

    "System.TickCount: This managed call returns the number of ticks that indicate the number of milliseconds. This is close to what we want, but we can do better."

    That one is also suitable...


  • Ather.

    Hi,

    I did not find a windows timer with that precision, more in the millisecs range.

    What I did was create a timer,

    static System.Timers.Timer timerOne = new System.Timers.Timer();

    An start it like so,

    //The Systems.Timers.Timer

    timerOne.Elapsed += new ElapsedEventHandler(TimerOneEventProcessor);

    //timerOne.Tick += new EventHandler(TimerOneEventProcessor);

    // Sets the timerOne interval.

    timerOne.Enabled = true;

    timerOne.Interval = 40;

    timerOne.Start();

    The timer callback would hold the code you want run at the interval, 40ms in this case.

    Here is the callback signature.

    private void TimerOneEventProcessor(Object myObject, EventArgs myEventArgs)

    {

    Jeff


  • Camillo777

    Yes,

    I noticed when I got to 50 - 60ms range it seemed to get a bit better, not totally accurate as time goes though, a bit jumpy.

    I will check out that article.

    Jeff


  • JRDodd

    the interval is in miliseconds.

    Just drag a timer (either one) onto the main form. Set the interval property to 20.



  • Timer Precision