Results 1 to 11 of 11

Thread: Timed Loops to Simulate Hertz

Threaded View

  1. #5
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,397

    Re: Timed Loops to Simulate Hertz

    I have a managed game loop timer codebank submission here: https://www.vbforums.com/showthread....aged-Game-Loop (this was written 7 years ago, might qualify for optimization).

    It also leverages QueryPerformanceCounters and QueryPerformanceFrequency, but the frequency is not a perfect 16.6ms elapse rate. It is usually off by a couple of couple hundreth to sometimes a full millisecond. I could never get it to consistently tick at 16.6ms and eventually gave up.

    My conclusion was that this was a limitation of VB.NET being a higher level programming language and WinForm technology being antiquated. I could be completely wrong, but I do remember spending significant time on trying to get this resolve only to come up short.

    Edit - Looking a little bit more, it seems as though QueryInteruptTimePrecise (documentation, only available Windows 10) may be more precise than QueryPerformanceCounters: https://docs.microsoft.com/en-us/win...on-time-stamps
    Last edited by dday9; Sep 21st, 2021 at 02:47 PM.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width