Re: letting a function timeout



El mié, 20-11-2002 a las 00:30, Thijs Assies escribió:
Hi,
I am using gnome-vfs to get a file. And i want GTK/GLIB to stop the 
function when it takes too long. gnome-vfs doesnt have a function like that.
Does anyone knows how to do this.


An idea:

#define SECS (5) /* 5 seconds timeout */
int timeout_id;
int timeout_period=1000*SECS;

timeout_func(gpointer data)
{
*data=TRUE;
gtk_timeout_remove(timeout_id);
}



function_get_file()
{
int timeout_flag=0;

timeout_id=gtk_timeout_add(timeout_period,timeout_func,(gpointer)&timeout_flag);
while(!tiemout_flag)
        {
                get_file_contents;
                ...
        }       
}

Regards.Juan.



thx.

thijs

ps: The gnome-vfs-mailinglist is dead :(


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

-- 
Juan Agüí Martín
ETSI Telecomunicación
C. Universitaria S/N Dpcho B-105
Madrid 28040 Spain




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