behavior of Windows.Forms.Timer vs WM_TIMER
-
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
-
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
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.
-
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
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.
-
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.
-
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.
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?
-
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?
If all the timers must have the same interval, the best option is to use only one timer for all.