Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. DispatcherTimer

DispatcherTimer

Scheduled Pinned Locked Moved WPF
data-structuresquestionannouncementlounge
6 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michaelbarb
    wrote on last edited by
    #1

    Why are ticks on a DispatcherTimer so unstable? Even at 500 msec. Is there anything you can due to stabilize it? I am reading analog data from IO and want to update the graph of it. It does not need to be that fast but it looks odd when it keeps jumping at an random intervals. I can deal with long jumps if they are consistent.

    So many years of programming I have forgotten more languages than I know.

    M D L 3 Replies Last reply
    0
    • M michaelbarb

      Why are ticks on a DispatcherTimer so unstable? Even at 500 msec. Is there anything you can due to stabilize it? I am reading analog data from IO and want to update the graph of it. It does not need to be that fast but it looks odd when it keeps jumping at an random intervals. I can deal with long jumps if they are consistent.

      So many years of programming I have forgotten more languages than I know.

      M Offline
      M Offline
      michaelbarb
      wrote on last edited by
      #2

      I should have noted that I can do a simple while loop with a sleep in it and get better results. It still seems like the tick from DispatcherTimer should do better.

      So many years of programming I have forgotten more languages than I know.

      1 Reply Last reply
      0
      • M michaelbarb

        Why are ticks on a DispatcherTimer so unstable? Even at 500 msec. Is there anything you can due to stabilize it? I am reading analog data from IO and want to update the graph of it. It does not need to be that fast but it looks odd when it keeps jumping at an random intervals. I can deal with long jumps if they are consistent.

        So many years of programming I have forgotten more languages than I know.

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        What interval and how far off are we talking? Windows is not a real-time O/S, so getting an exact interval isn't possible. Events or callbacks are guaranteed to occur NO SOONER THAN your interval. That doesn't mean that it will execute ON that interval.

        Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
        Dave Kreskowiak

        M 1 Reply Last reply
        0
        • D Dave Kreskowiak

          What interval and how far off are we talking? Windows is not a real-time O/S, so getting an exact interval isn't possible. Events or callbacks are guaranteed to occur NO SOONER THAN your interval. That doesn't mean that it will execute ON that interval.

          Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
          Dave Kreskowiak

          M Offline
          M Offline
          michaelbarb
          wrote on last edited by
          #4

          I sat the interval for 500 ms. Hard to measure but the trace has a jerky motion. It is much smoother when I use a simple while loop with a sleep in it. Setting the sleep for 20ms gives a nice smooth plot.

          So many years of programming I have forgotten more languages than I know.

          1 Reply Last reply
          0
          • M michaelbarb

            Why are ticks on a DispatcherTimer so unstable? Even at 500 msec. Is there anything you can due to stabilize it? I am reading analog data from IO and want to update the graph of it. It does not need to be that fast but it looks odd when it keeps jumping at an random intervals. I can deal with long jumps if they are consistent.

            So many years of programming I have forgotten more languages than I know.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Quote:

            Timers are not guaranteed to execute exactly when the time interval occurs, but they are guaranteed to not execute before the time interval occurs. This is because DispatcherTimer operations are placed on the Dispatcher queue like other operations. When the DispatcherTimer operation executes is dependent on the other jobs in the queue and their priorities.

            In other words, you need a separate timing device if you want "stability".

            It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

            M 1 Reply Last reply
            0
            • L Lost User

              Quote:

              Timers are not guaranteed to execute exactly when the time interval occurs, but they are guaranteed to not execute before the time interval occurs. This is because DispatcherTimer operations are placed on the Dispatcher queue like other operations. When the DispatcherTimer operation executes is dependent on the other jobs in the queue and their priorities.

              In other words, you need a separate timing device if you want "stability".

              It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

              M Offline
              M Offline
              michaelbarb
              wrote on last edited by
              #6

              It is probably also effected by the debugger in Visual Studio. It really makes the DispatcherTimer useless for delays under a minute.

              So many years of programming I have forgotten more languages than I know.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups