The Windows Forms timer is ultimately limited by the resolution of the standard system clock resolution of your computer. It depends on the computer and the computer, but usually ranges from 1 ms to 20 ms.
In WinForms, whenever you request a timer interval in your code, Windows ensures that your timer is not called more often , and then the number of milliseconds is indicated. This does not guarantee that your timer will be called in exactly the specified milliseconds.
This is due to the fact that Windows is an OS that runs on time, and not in real time. Other processes and threads are scheduled to be launched at the same time, and therefore your thread will be forced to regularly wait for processor usage. Therefore, you should not write WinForms timer code, which depends on the exact intervals or delays in milliseconds.
In your situation, setting the interval to 1 ms really just tells Windows to start this timer as often as it can. As you have seen, this is definitely much less common than 1 ms (60 frames per second = about 17 ms).
If you need a more accurate and higher resolution timer, the Windows API provides high resolution / performance timers, if your equipment supports it, see How to do it, use a high resolution timer . The disadvantage of this is that the use of your application processor will be increased to support higher performance.
In general, I think that you are better off implementing a hardware / system independent game loop. In this way, the perceived animation of your scene becomes constant regardless of the actual frame rate achieved. For more information, these articles provide a good background.
Ash
source share