WxIdleEvent

From WxWiki
Jump to navigation Jump to search

Overview

wxIdleEvents are the proper event to hook up to doing things when the processor has a breath, for example sucking some output from a running piped process.

To use them, put an EVT_IDLE in your event table, and hook it up to some function you want fired on an idle event.

Workarounds

Forcing generation of idle events when they aren't being produced

For me I couldn't get any wxIdleEvents in Borland C++ when compiled in release build (they worked in the debug build though).

So, to force idle events to be generated (the simple way):

  • Have a timer, and include the timer event in the suitable event table. Have the timer hooked up to a function that includes a call to wxWakeUpIdle().
  • Start the timer with the desired interval of milliseconds you want idle events to be generated.

Now you will get an idle event at the specified interval.

The above way works and gets the job done. There is apparently another way to do this (involving separate worker threads).