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
On Thu, Apr 29, 2010 at 4:54 PM, Hurier M?d?ric <lists at
ruby-forum.com>wrote:
> Hi there,
>
> I''m developping an application based on xmpp4r and WxRuby to
download
> file between contacts. My application must handle incoming request and
> manage all the file upload proccess.
>
> Unfortunately, all proccess in Wx::App are active only if the
> application has the focus or receive an event.
> For example, I must move my cursor on the main window or click on it if
> I want the user interface to be refreshed (contact go online/offline).
>
> Is there a way to set that the Wx application must continue its actions
> allthough it has not the focus ?
>
> Thank you
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> wxruby-users mailing list
> wxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wxruby-users
>
--
Mario Steele
Lieutenant 3 - Geo 99
XO - STO IFT Fleet
Chief Engineer - Second Life
http://www.iftcommand.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/wxruby-users/attachments/20100429/28ed4c59/attachment.html>