Re: Question on C



On Thu, Jan 29, 2004 at 11:00:26AM +0100, Daniel Miralles Garc?a wrote:
This hasnt anything to do with GTK+ but I was wondering would any one
know how to program in a delay( say a delay of 2 seconds after clicking
on a button before another event happens). Cheer

Hi.

If you want a miliseconds pause, you can use this:

void pause (int sec, int msec)
{
      struct timespec delay;
      delay.tv_sec=sec;
      delay.tv_nsec=msec*1000000;
      nanosleep(&delay, NULL);
}

For instance, pause(0,250); makes a 0'250 seconds pause :)


You should probably name it something other than pause as there is a
POSIX function of the same name.

--jkl



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