long StartTime=time(NULL);
while (time(NULL)-StartTime<**) 
{
     Sleep(1000);
     *****;
}此句的用途是什么?

解决方案 »

  1.   

    long StartTime=time(NULL);//记录开始时间//计算当前时间和开始时间之差,如果小于一定的阈值,则进入循环
    while (time(NULL)-StartTime<**) 
    {
         Sleep(1000);  //停留一秒
         *****;        //在循环中做点别的事,天知道是什么事 ,^_^
    }
      

  2.   

    time(NULL) 好像只能取到秒,不能到毫秒?double StartTime=time(NULL);
    while (time(NULL)-StartTime<**)  //我想要判断条件为10毫秒,不知怎么做?  
    {
         Sleep(1000);
         *****;
    }
      

  3.   

    Example
    The following example demonstrates how to handle timer wrap around.DWORD dwStart = GetTickCount();// Stop if this has taken too long
    if( GetTickCount() - dwStart >= TIMELIMIT )
        Cancel();——摘自MSDN