Re: Gtk+ & time-consuming threads

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

 





2009/5/6 patkhor <indyz-fluke@xxxxxxxxxxx>

Hi,

I'm trying to add GUI for my application and I choose to do it with Gtk+.
I've asked on this forum before about multithreading, but I still can't get
it right. I found few examples on how to use gthread on the web, but none of
them answers my question.

My problem is:
I provide the user with the OK button, when user click on that button, the
program will create some number of threads (more than 10) and each threads
will do time-consuming work in the background. I successfully compiled my
program, but when I click on OK button, the main window freeze (display "not
responding" message on Windows machine).

One person on this forum suggested to me (thank you very much) that I should
make the threads unjoinable because the main thread have to wait for all
threads to finish their execution that's why the main window freeze. So I
eliminate all g_thread_join() but the problem still occur.

Could someone please give me little sample code that provide only one
button. When that button is clicked some number of threads will do something
time-consuming in the background (something simple like multiplying numbers
1000 times in the for loop, just to give me an idea).

Here is a very simple example to get you started. It will be easy to add thread joining, and it's missing some locking.

Vivien

Attachment: ThreadButton.tbz
Description: application/bzip-compressed-tar

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux