I need to make a simple enough program in C#, but it seems to be impossible via usual WinForms means. I need to show something (a string of text, an image) on the screen for very small time interval. Since typical monitors are 60Hz, this interval would be 1 or 2 frames (16,6 or 33,3 ms). I tried doing this with usual WinForms, and it is not possible because, apparently, there is no way to know how many frames were output to the monitor since some point in time. I can only draw on the controls, and monitor output is totally independant.
So even if I run the timer, say, for 17 ms, between showing and hiding the image, it still sometimes manages not to draw a single frame of my image on the screen (even though theoretically it should, because 17ms > 16,6ms). Moreover, even 20ms seems to slow (even though i should be more than enough).
I did some game development as a hobby in the past (Delphi X, XNA) and I know that you usually draw the whole screen by yourself, each frame. Also, I know that there is an option called Vsync in most modern games, that allows you to synchronize your framerate to your monitor's frame rate.
So, is it possible? I mean, to actually know how many frames were sent to the monitor with w/e I want to show?
EDIT:
After doing some study, I guess there really is no way to check when monitor is updated. All you can do is use vsync - and all that does it just pauses your double-buffer-flipping until right after monitor refresh. Which would achieve what I want... if only it would be possible to guarantee that it will actually work! Turns out, it works only if it was not disabled previously in one of the million ways to disable it (like, in the driver, in the driver-bundled software, and wherever else).
I guess there is no way from your software to check if vsync is disabled in the driver either... Or is there? I guess only outputting several frames and checking timestamps between them - like, does outputting a blank screen and swapping buffers takes 16,(6)ms or 0,1 ms.
Anyways, I think I'll be using C# SDL and try to somehow do it via setting double buffering and swap control... If someone has useful information to add though, please do!