urbanspr1nter
urbanspr1nter

Reputation: 1357

Using QueryPerformanceCounter at Intervals in VB.NET

I was wondering if I could somehow get some guidance on using QueryPerformanceCounter/Frequency on performing a task at every interval in VB.NET. Let's say for example every 6 micro-second.

I was thinking maybe find the time now and do a mod on 6us, but there would lead to precision issues?

Thanks everyone.

Upvotes: 1

Views: 1027

Answers (1)

Florian
Florian

Reputation: 5994

You could create a "timer-class" that stores the previous time and interval. Then create a method like Update(). In that method you check the current time of something like a stopwatch and compare it with the previous time and the interval. If you are to early just sleep the rest of the time. Thats princip of games are working.

Upvotes: 1

Related Questions