Is the next Notify() suppressed, queued or executed "simultaneously"?
Can/should I check for this case?
Would it be OK instead to use a single-shot timer with a StartOnce() at the end of the Notify()?
I have my doubts about the latter because the documentation states that "A timer can only be used from the main thread".
Thanks in advance!
What happens when code in Notify() of wxTimer takes longer than the timer interval? Topic is solved
What happens when code in Notify() of wxTimer takes longer than the timer interval?
Last edited by macsinus on Wed Feb 24, 2016 8:00 am, edited 2 times in total.
Re: What happens when code in Notify() of wxTimer takes longer than the timer interval?
Usually, I use a 'one-shot' timer and trigger another one in the handler itself.
This way I assure that the timer starts again once the handler code is done.
Eran
This way I assure that the timer starts again once the handler code is done.
I don't see any problem with this, since the handler is also called in the main threadI have my doubts about the latter because the documentation states that "A timer can only be used from the main thread".
Eran
- T-Rex
- Moderator
- Posts: 1248
- Joined: Sat Oct 23, 2004 9:58 am
- Location: Zaporizhzhya, Ukraine
- Contact:
Re: What happens when code in Notify() of wxTimer takes longer than the timer interval?
On Windows the timer window message has the lowest priority and when you start the timer, the system does not guarantee that the message will be sent if the thread's event loop is busy processing other window messages. So if your timer window message handler works longer than the timer's interval, most likely you will not get the next timer message.
And since the main thread has only one event loop, then your window procedure will not get the next message until you process the current one, I assume.
And since the main thread has only one event loop, then your window procedure will not get the next message until you process the current one, I assume.
Re: What happens when code in Notify() of wxTimer takes longer than the timer interval?
Hello Eran,
thank you for your quick reply and for the good news that the "chained" one-shot timer solution works - I'll go along this route.
Somehow I had assumed that the Notify() would be executed within a different thread.
Now that I know that it is in the main thread I don't need to have any headaches regarding display updating either.
Thanks also T-Rex; another good reason to do it this way.
thank you for your quick reply and for the good news that the "chained" one-shot timer solution works - I'll go along this route.
Somehow I had assumed that the Notify() would be executed within a different thread.
Now that I know that it is in the main thread I don't need to have any headaches regarding display updating either.
Thanks also T-Rex; another good reason to do it this way.
Re: What happens when code in Notify() of wxTimer takes longer than the timer interval?
Just to confirm - I've now implemented this so and it works like a charm.
Thanks again!
Thanks again!
wxWidgets 3.1.0
Boost 1.65
VS 2017
Win 7
Boost 1.65
VS 2017
Win 7