Thanks James for giving me my first experience with Thread programming!
I tried the code you sent me, but unfortunately, I still can't get the  
progress_update
function to run, looks like it never gets called. Any idea why this  
might be happening?
growPart still runs.

Thanks,

Vicki


[Hide Quoted Text]
GTK program before.  The ret=wait(null) causes execution to stop at that

point and wait for growPart() to finish.  A way to get around the  
logistics of fork() is to use threads directly.  Consider the following;

/* globals */
gboolean  b_pulse_control = FALSE
GThread  *grow_thread_id = NULL;
gint   global_ret = 0;


b_pulse_control = TRUE;
timer = g_timeout_add(50, (GSourceFunc) progress_update,
(gpointer)progressbar);

grow_thread_id = g_thread_create ( growPart_thread, &b_pulse_control,
TRUE, NULL);


static gboolean progress_update (gpointer progressbar)
{
      if (b_pulse_control)
     {
          gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progressbar));
          return true;
     } else {
         global_ret = GPOINTER_TO_INT( g_thread_join (grow_thread)  );
         return FALSE;
     }

}

static gpointer growPart_thread(gpointer b_pulse)
{

      /* do work */
      growPart();

      *b_pulse = FALSE;
      g_thread_exit( GINT_TO_POINTER( 1 ) );

}

I would do the passing of control values via a structure to avoid  the  
use of globals,
but this should work for you.


------------------------------------------
Invent your own San Diego at sandiego.com!


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

Reply via email to