Re: letting a function timeout



On 20 Nov 2002 09:43:19 +0100
Juan Agüí <jagui die upm es> wrote:

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)&tim
eout_flag); while(!tiemout_flag)
      {
              get_file_contents;
              ...
      }       
}

I don't know gnome-vfs, but can't he define a SIGALRM for that sort of
job?

bye



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