Re: GUI still hanging...



In message <39078039.39598FE3@cs.nmt.edu>you write:
>Paul Barton-Davis wrote:
>> Sorry, this is wrong. This loop will simply flush out existing events,
>> and then breaks...
>
>Yup, you're right. That while loop never ran even
>once. However, what I ended up doing was making
>an int* that I set to 1 before running my thread
>and then I do my while loop testing that integer.
>Once my thread completes, I set my int* to 0
>and the while loop quits and pthread_join() is
>called. This seems to work! I'm very happy. Here's
>my code below. I'm not sure if this is very efficient,
>but it seems a tad simpler than using pipes. Thanks
>for your help, though!

It certainly is. I didn't know that the ftp thread was going to exit
once the connection was setup up. If it didn't exit, then you'd still
block the GUI when you call pthread_join. I suppose you could simply
change the semantics of "*connecting" to "thread still active", and it
would work as well. Nice solution. In general, I prefer to return to
the "main level 1" rather than remain in a nested call to
g_main_iteration(), though I understand that glib is designed to allow
this without any real overhead or penalty.

I may use this design in a vaguely similar situation I have, where I
am loading data from disk or allocating 100's of MB of disk
space. Your scheme is much simpler for that kind of thing. Thanks.

--p




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