Thanks Robert I have created the loop in another thread and have
Gtk:dispatcher to trigger event back and forwd to the main thread.

Cheers,

Kiet Tran

On Thu, Mar 1, 2012 at 6:58 PM, Robert Pearce <[email protected]>wrote:

> Hi kiet,
>
> On Thu, 1 Mar 2012 18:00:31 +1100 you wrote:
> >
> > I'm in a situation where I need to stay in a loop to listen for data from
> > the other end of socket connection, and at the same time I want to
> > update/display my GUI according to the information coming in.
> >
> OK
>
> > The GUI that going to display these informations is a pop-up diaglog box.
> >
> OK
>
> > So I  think to fix this I need to spawn a thread for the pop-up diaglog
> box.
> >
> No, you don't. At least, that certainly isn't the ONLY solution, and in
> GTK it's almost certainly not the best or easiest solution either.
>
> The option I'd look at first is to remove the "stay in a loop" you
> first mentioned. Hook up your socket to a GIO::Channel (not sure on
> name, I use the unwrapped g_io_channel_... method) and then connect a
> handler to that channel's event signals. That way you can process the
> incoming data within the GLib/Gtk main loop. No need for threads at all.
>
> The other option to look at is to leave your whole GUI running in the
> main thread, but to launch your "loop to listen for data" into a second
> thread. That thread can then buffer the data and use a GLib::Dispatcher
> to trigger a main thread call-back to handle it (which I think is what
> GIO::Channel does internally on some platforms). Alternatively the
> socket thread could process the data and use a GLib::Dispatcher to
> trigger a dialog update. There's an example of this in the GLib-mm docs
> at gnome.org
>
> > Thus could some one please point me to some websites that show me how to
> > operate multi threading in gtkmm or sample code to get a simple one
> > running, thank-you.
> >
> www.gnome.org/docs/glibmm/group__Threads.html (or some variant of that
> - I'm looking at a local copy that was installed with the package)
>
> Rob
> _______________________________________________
> gtkmm-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to