Re: GUI very slow when sleep() called...



On Tue, Oct 03, 2000 at 05:09:59PM -0400, Andy wrote:
cyrusp cia com au wrote:
In an app I'm writing I have to put a usleep(100000) call in my
code. However when I do this my gui becomes very slow and unresponsive -
understandibly since I'm doing it in the gtk_main loop...

Is there a way to sleep but refresh the gui at the same time?

Instead of sleeping, use a timer.
If that's a pain, perhaps you can have code like
    while (gtk_events_pending()) {
        gtk_main_iteration();
        if (weWaitedLongEnough) {
            break;
        }
    }
and have a timer set the weWaitedLongEnough variable.

Or, check with gettimeofday() each time round the loop, but that's
slightly slower and probably less portable to non-Unix systems.

It all depends on why you are using the sleep.

Lee

-- 
Liam Quin - Barefoot in Toronto - liam holoweb net - http://www.holoweb.net/
Ankh: irc.sorcery.net www.valinor.sorcery.net irc.gnome.org www.advogato.org
author, The Open Source XML Database Toolkit, Wiley, August 2000
Co-author, The XML Specification Guide, Wiley, 1999




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