Re: [gtk-win32] Updating a progress bar from a worker thread



Il giorno sab, 19/12/2009 alle 15.46 +0000, John Emmas ha scritto:
> ----- Original Message ----- 
> From: "Pietro Battiston"
> >
> > I think it's right to say that thread are rarely needed in gtk
> > application, and threads that play with the interface can almost always be
> > avoided
> >
> Thanks Pietro.  Actually, you've brought up something here that's puzzled me
> ever since I first started looking at GTK development (initially under
> Linux).
> 
> I too have noticed that GTK programs written by other programmers do have a
> tendency to run everything within the main UI thread.  Unfortunately, I've
> also noticed how unresponsive these apps can get when they're busy with a
> lengthy task.

Absolutely: this is the case in which a thread does make sense. Though
as I wrote I generally try to avoid asking the threads to play with the
GUI directly - for instance in [0] I have threads but then only the main
one interacts with gtk - you reminded me of a case where I do use a
thread to update a progressbar, and I don't use gtk_events_pending() or
gtk_main_iteration(): you can find it at [1], and though I never tested
it under Windows, you can try (and the classes Progress and
ThreadedProgress are fairly simple and should have all you need - just
define run()), so that at least you know if you are facing a
Windows-specific problem.

cheers

Pietro

[0]: http://www.pietrobattiston.it/momail
[1]: http://www.pietrobattiston.it/gallery_uploader



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