Hello Hurier,
There is two ways in which you can do this. The first method, is to use
a
Wx::Timer and Threads. It depends on if you are using Ruby 1.9 or Ruby
1.8
in the method in which you can execute this.
If you are using Ruby 1.8
You create a Thread that will do your Xmppr processing, and then you
setup a
timer, that will after so many seconds or Milliseconds, does a Thread
switch, to allow other ruby threads to run. You can find an example of
this
in my Sockets examples distributed with wxRuby.
If you are using Ruby 1.9
You can simply just create the Thread, and it will auto-context switch
for
you, as Ruby 1.9 uses native threads, instead of Soft Threads, as with
Ruby
1.8, hence for the work around provided in the sockets demo.
The second method in which to implement this, is to use the evt_idle
method
in your initialization method for your Window class, which will call the
method that handles the Xmppr processing, and occasionally checks for
Events
to be generated by the wxWidgets, by using Wx::App.pending? Which
returns
true if events are pending, otherwise false.
Idle events are generated once for entering an Idle state. So, if you
do
nothing with your app for a second, it will generate an idle event,
evt_idle
will execute once, and then it will wait for new events to occur. When
a
new event occurs for anything, the event will fire, then it will wait
for a
second then generate another idle event.
The timing in the above explination is only an example, and does not
expressly garuntee that the idle event will execute 1 second after no
other
events occur.
hth,
Mario