Re: When to use thread/fork?



On Tue, Jan 18, 2005 at 08:54:41 +0100, Benoît Touron wrote:
> Miguel,
> 
> The easiest way is to use threads (the Glib API is conveniant and 

Easiest way is to use explicit invocations to Gtk::Main::iteration or
idle handlers. You don't have to bother about synchronization that way.

> portable). Whith processes, you will fall into inter-process 
> communication problems.
> You time consuming action should be processed by a separate thread, 
> which can be blocked without freezing your GUI. Nevertheless, all of the 
> GUI items must be managed by one single thread thread (the main thread).
> If you need your second thread to update a progress bar, then you should 
> use the Glib::dispatcher object to send a message to your main thread, 
> which will actually update the progress bar. If you try to modify the 
> progress bar directly from the second thread, you program will crash, 
> today or tomorrow.
> 
> Ben
> 
> >-----BEGIN PGP SIGNED MESSAGE-----
> >Hash: SHA1
> >
> >Hi all.
> >
> >One of my application actions is time consuming, and I want to be
> >lauched in a separate process/thread, with it's own dialog and its own
> >progress bar. I don't want the GUI to get freezed waiting that action to
> >complete (ugly!)
> >
> >So, what's the best way to get this? Must I use glibmm threads? Maybe
> >forking is enough?? Maybe i must not fork... maybe it can be done using
> >one single thread... I'm asking because related documentation is very
> >sparse, and I'm lost.
> >
> >What are your advices?
> >
> >
> >
> >
> >
> >
> >
> >-----BEGIN PGP SIGNATURE-----
> >Version: GnuPG v1.2.6 (GNU/Linux)
> >Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
> >
> >iD8DBQFB7IpbZSBU6dC79g0RAioCAJwNLkWFYn2wNwcAQFLk9r5q54wBGACaAp8z
> >t5e1djGFMp8GRiOIOWGFkzo=
> >=tA6z
> >-----END PGP SIGNATURE-----
> >_______________________________________________
> >gtkmm-list mailing list
> >gtkmm-list gnome org
> >http://mail.gnome.org/mailman/listinfo/gtkmm-list
> >
> 
> 
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 
-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb ucw cz>

Attachment: signature.asc
Description: Digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]