Re: When to use thread/fork?



Miguel,

The easiest way is to use threads (the Glib API is conveniant and 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






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