pthreads



Hello everybody:

I have a programm than read from the standar input using fgets, so it will
block till there are some data ready to read.
I want a progress bar to show activitie.
Because the program blocks in fgets. the movement of the progress bar is no
constant. 

So i create a pthread to move the progress bar as in the faq 5.2 indicate

main()
{

g_thead_init(NULL);
....
...
gdk_threads_enter();
gtk_main();
gdk_threads_leave();
}


callback_function()
{
...
pthead_create(thread_t,NULL, thread_function, progress_bar);
fgets(....);
...
}

thread_function
{

while(1)
{
gdk_threads_enter();
gtk_progess_set_value(progress_var, value);
gdk_threads_leave();
sleep(1);
}

}


If i do this way, the thread will block in the gdk_threads_enter(),
if i take away the gdk_threads_enter the thread progress, but it doesn't
move the progress bar
Can anybody helpme???
 




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