[wxruby-users] Question about WxNotebook, threads, and GUI refreshing
Alex Fenton
alex at pressure.to
Wed Jan 16 17:41:49 EST 2008
Hi Alex
Alex Ciarlillo wrote:
> I'm running into a problem I've had before with wxRuby where the GUI
> does not update while my App is processing some set of data. The fix for
> this I know is to put the data processing piece in a new thread and in
> the Wx::App code make a timer to pass the threads. This has always
> worked in the past, but now my problem is slightly more complex and I'm
> at a loss.
>
I can't see anything wrong with the way you've set things out. As the
etc/threaded.rb sample shows, there should be no problem with having
multiple ruby 1.8 threads running in the background of a wxRuby application.
Perhaps ensure that you set abort_on_exception = true for each of the
child threads. I've sometimes been puzzled that a thread's not running,
only to find that there's some bug in the thread's code which means it's
crashed and stopped, but silently.
Incidentally, as of wxRuby 1.9.4, you'll be able to use a slightly
neater notation to pass control among ruby threads, eg:
Wx::Timer.every(50) { Thread.pass }
to rotate every 50ms
> Basically I am trying to put together a bunch of small reporting apps
> I've made into one single application using tabs to separate them.
THere's probably different ways to design this. Depending on what the
child notebooks are doing, you could run two timers, one to make ruby's
threads run, and another to check a queue for updates to the GUI. Then
the child threads could add updates to this queue.
alex
More information about the wxruby-users
mailing list