Search code examples
wxwidgets

wxWidgets: is it possible to nest two different wxTimers?


I am writing an application that stays in the traybar and do some checks every some minutes. When it performs this checks, I would like the traybar icon to be animated. That is why I have a first wxTimer triggering checks. In its OnTimer call I tried to manage the second wxTimer to handle the animation.

The issue is that timers work in the mainloop, so the icon is not updated when the second timer updates the icon index.

Is there a way to overcome this problem?

Thank you!


Solution

  • Your description of the problem is unfortunately not clear at all but if you mean that you don't get timer events until you reenter the event loop, this is indeed true and, moreover, almost tautological -- you need to return to the event loop to get any events.

    This is the reason why your event handlers should always execute quickly and return control to the main loop. And if they take too long, the usual solution is to use a background thread for the real work and just schedule it in your event handler, but not wait until it is done.