Newsgroups: comp.windows.ms.programmer
Path: funic!fuug!mcsun!inesc.inesc.pt!jana!vga
From: vga@jana (VGA alunos )
Subject: Precision delays in Windows.
Message-ID: <1993Jan29.191200.12731@inesc.pt>
Sender: usenet@inesc.pt (USENET News System)
Nntp-Posting-Host: jana.inesc.pt
Organization: INESC (Inst. Eng. Sistemas e Computadores)  -LISBOA -PORTUGAL
X-Newsreader: Tin 1.1 PL3
Date: Fri, 29 Jan 1993 19:12:00 GMT


   I'm having a problem in making a routine that just makes a small delay of    miliseconds specified by his parameter.

   I've first tryied to use the system routine GetSystemTimer ...


      
      void delay(DWORD mSeconds)
      {
	 DWORD aux = GetSystemTime( );
	 DWORD curr=aux;

	 while( curr-aux < mSeconds) curr = GetSystemTime();
	}

     but when I've tryied to make  a delay(10) 100 times instead of taking 1    second it has taked 5 seconds.
     I've also replaced GetSystemTime by the routine TimerCount (with the adequate code) but stranger    problems have appeared.
     When I call TimerCount the first time and imediatelly next I call TimerCount again ,in the second call I get an elapsed time less than the first call(!!)

     How can I turn around that problem??
     Is there a bug in TimerCount?I guess so!!

     Please help me sending your answer to the News.


