Re: Gtk+ and multithreating



Am 2007-05-15 11:28:45, schrieb chabayo:
Hi list,...

...im sorry if i missunderstand something...

Maybe :-)

Am 14.05.2007 19:53:44 schrieb(en) Michelle Konzack:
----8<--------------------------------------------
   window_main=create_window_main();

   while ( TRUE )
   {
     while ( gtk_events_pending() )
       gtk_main_iteration();

     <some_code_to_update_the_dialog>
   }
----8<--------------------------------------------


...could it be two threads try updating the same GUI-Structure !? -  
trying to resolve their reflections of their updates on the Object-Tree  
or something that way??

main() {
  pthread_t tids[10];

  while ( TRUE )
  {
    while ( gtk_events_pending() )
    gtk_main_iteration();

    pthread_create(tids + 1,
                   NULL,
                   my_cool_func,
                   (void *)(param));

    <some_code_to_update_the_dialog>
  }
}

void my_cool_func(vid *param) {
  ...
  <update_the_list>
  ...
  return 0;
}

Ok, im still here...hope i understand...u get in to the update  
function...and update some widgets!?? - or what...

right

...or it just takes to much time to calculate the data, and for that  
time your (main-)thread cannot update the gui.

Right too.

Quering 2300 Maildir-Folders would block your GUI (GtkTreeView for
the directories with the unread messages)for the neyt 2 hours.

So I put the c-client routine for quering the mailfolders in a pthread
and it run asyncrounous

Oh, with the above example, I see, while I am in the GUI and do
something, the pthreaded function is querying the imap server

I have put printf all over the source code to get stamps on stdout.
(can be dangerous if you run moe then one thread...)

Then it should work as i said...

-signal to update data starts 2nd thread
-main thread does normal gui response
-2nd thread got data

OK

-2nd thread comes into situation to have to lock (thats that thing i  
have "had" a link for) some gui-data so main thread does not conflict  
with

right.

But for now, the NEW data was collected by the pthtead_create(my_cool_func)
and now I do not know, how to get it back into the GtkTreeView()

Hey, coding is just fun, even if the learning courve is sometimes very steep.

Thanks, Greetings and nice Day
    Michelle Konzack
    Systemadministrator
    Tamay Dogan Network
    Debian GNU/Linux Consultant


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
##################### Debian GNU/Linux Consultant #####################
Michelle Konzack   Apt. 917                  ICQ #328449886
                   50, rue de Soultz         MSN LinuxMichi
0033/6/61925193    67100 Strasbourg/France   IRC #Debian (irc.icq.com)


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