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. C#
  4. behavior of Windows.Forms.Timer vs WM_TIMER

behavior of Windows.Forms.Timer vs WM_TIMER

Scheduled Pinned Locked Moved C#
visual-studiodata-structuresquestion
6 Posts 4 Posters 0 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
    manustone
    wrote on last edited by
    #1

    Hi All I have a small doubt regarding a Forms.Timer and WM_TIMER. If I remember right each System.Windows.Timer.Forms triggers an event ( bounded to the Tick event ) for each WM_TIMER message coming from the message pump of the Form where is included. Since each of this WM_TIMER messages comes from the main message queue of Window OS, if I Have 30 forms on my screen, each with its own Forms.Timer object updating some graphic component of the form (label text, or other ), can I say that each form will be strictly updated one after one? I don't know how WM_TIMER is dispatched and processed in each form given that the queue of the OS is unique and shared by all the forms. Regards Manustone

    S R 2 Replies Last reply
    0
    • M manustone

      Hi All I have a small doubt regarding a Forms.Timer and WM_TIMER. If I remember right each System.Windows.Timer.Forms triggers an event ( bounded to the Tick event ) for each WM_TIMER message coming from the message pump of the Form where is included. Since each of this WM_TIMER messages comes from the main message queue of Window OS, if I Have 30 forms on my screen, each with its own Forms.Timer object updating some graphic component of the form (label text, or other ), can I say that each form will be strictly updated one after one? I don't know how WM_TIMER is dispatched and processed in each form given that the queue of the OS is unique and shared by all the forms. Regards Manustone

      S Offline
      S Offline
      Saksida Bojan
      wrote on last edited by
      #2

      manustone wrote:

      can I say that each form will be strictly updated one after one?

      No, you can't predict order of update. I woud recommend a custom event placed on a global, so that all forms inside process coud accsess and one timer. Every form can subscribe to that event, and Timer.Tick event can fire other events in other of subscription.

      M 1 Reply Last reply
      0
      • M manustone

        Hi All I have a small doubt regarding a Forms.Timer and WM_TIMER. If I remember right each System.Windows.Timer.Forms triggers an event ( bounded to the Tick event ) for each WM_TIMER message coming from the message pump of the Form where is included. Since each of this WM_TIMER messages comes from the main message queue of Window OS, if I Have 30 forms on my screen, each with its own Forms.Timer object updating some graphic component of the form (label text, or other ), can I say that each form will be strictly updated one after one? I don't know how WM_TIMER is dispatched and processed in each form given that the queue of the OS is unique and shared by all the forms. Regards Manustone

        R Offline
        R Offline
        Rob Philpott
        wrote on last edited by
        #3

        30 forms on your screen? I do hope you have a large monitor. Each form, being a window has its own message loop. WM_TIMER messages are posted (ie. asynchronous) to the loop and are fired pretty much 'on idle'. Should one of you forms be busy, the timer event won't get through so you really can't guarantee order, or for that matter regular updates.

        Regards, Rob Philpott.

        M 1 Reply Last reply
        0
        • S Saksida Bojan

          manustone wrote:

          can I say that each form will be strictly updated one after one?

          No, you can't predict order of update. I woud recommend a custom event placed on a global, so that all forms inside process coud accsess and one timer. Every form can subscribe to that event, and Timer.Tick event can fire other events in other of subscription.

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

          Thanks for your response!

          1 Reply Last reply
          0
          • R Rob Philpott

            30 forms on your screen? I do hope you have a large monitor. Each form, being a window has its own message loop. WM_TIMER messages are posted (ie. asynchronous) to the loop and are fired pretty much 'on idle'. Should one of you forms be busy, the timer event won't get through so you really can't guarantee order, or for that matter regular updates.

            Regards, Rob Philpott.

            M Offline
            M Offline
            manustone
            wrote on last edited by
            #5

            Hi Rob! Thanks for your reply! So at the end regular updates cannot be guaranteed using WM_TIMER. What if I use 30 System.**Threading.**Timers for that purpose? Do C# create a thread for each System.Threading.Timers or not? If it does than probably it is better a ThreadPool.. what are your thoughts?

            P 1 Reply Last reply
            0
            • M manustone

              Hi Rob! Thanks for your reply! So at the end regular updates cannot be guaranteed using WM_TIMER. What if I use 30 System.**Threading.**Timers for that purpose? Do C# create a thread for each System.Threading.Timers or not? If it does than probably it is better a ThreadPool.. what are your thoughts?

              P Offline
              P Offline
              Paulo Zemek
              wrote on last edited by
              #6

              If all the timers must have the same interval, the best option is to use only one timer for all.

              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