home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / mswindo / programm / misc / 3533 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  1.8 KB

  1. Path: sparky!uunet!utcsri!skule.ecf!torn!nott!cunews!revcan!software.mitel.com!kim!kim
  2. From: kim@Software.Mitel.COM (Kim Letkeman)
  3. Newsgroups: comp.os.ms-windows.programmer.misc
  4. Subject: Re: Inaccuracy in windows timer?
  5. Message-ID: <KIM.92Nov18122028@kim.Software.Mitel.COM>
  6. Date: 18 Nov 92 17:20:28 GMT
  7. References: <1992Nov18.113155.165165@dstos3.dsto.gov.au>
  8. Sender: kim@Software.Mitel.COM
  9. Organization: MITEL Public Switching, Kanata, Ontario, Canada
  10. Lines: 27
  11. In-reply-to: jav@dstos3.dsto.gov.au's message of 18 Nov 92 17:31:54 GMT
  12.  
  13. In article <1992Nov18.113155.165165@dstos3.dsto.gov.au> jav@dstos3.dsto.gov.au writes:
  14.  
  15. | I realise that the windows timer is only accurate to 18.2 ms, but
  16. | surely the settimer function is able to correct for non-multiple of
  17. | 18.2 ms intervals (obviously not!).  If not, then does any Guru out
  18. | there know how I can correct the time to accurately be able to
  19. | sample every sixty seconds?
  20.  
  21. Page 175 of Petzold, 2nd Edition:
  22.  
  23.         - The time interval you specify in the SetTimer call is always
  24.       rounded down to an integral multiple of clock ticks. For
  25.       instance, a 1000-msec interval divided by 54.925 msec is
  26.       18.207 clock ticks, which is rounded down to 18 clock ticks,
  27.       which is really a 989-msec interval.
  28.  
  29. Your other choice is to code your own message loop to delay until the
  30. next interval is over. You can do a peek message and the usual
  31. processing, including translate and dispatch and in between you can
  32. check the time. When you reach your time, go for it.
  33.  
  34. Note that no matter what you do, Windows still does cooperative
  35. multi-tasking, so that any one of your samples could be off by more
  36. than a second if some other app held the CPU at the critical moment.
  37. This would not affect the timer interval of course.
  38. --
  39. Kim Letkeman    kim@Software.Mitel.COM
  40.