Posted on 2001-08-06
I need a better timer than the TTimer component. I know there is no perfect timer under Windows 95, but what the TTimer does is quite unacceptable. (The TTimer gives on a 100 MHz Pentium, with the timer interval set to 1, about 24 timer events per sec -- instead of 1000! Note that the test application was 'honest', doing nothing else in the OnTimer event handler than incrementing a counter.)
I have had the followings ideas.
1. Modifying the priority of the main thread, with the following code in the OnCreate method of the main form:
It makes ABSOLUTELY no difference.
2. Using the SetTimer API function with callback function instead of message posting. I haven't tried it, because the Win32 help says the following:
"When you specify a TimerProc callback function, the DispatchMessage function simply calls the callback function instead of the window procedure. Therefore, you need to dispatch messages in the calling thread, even when you use TimerProc instead of processing WM_TIMER."
So I have the feeling that it won't help me either.
3. Using a driver-level IRQ callback function.
I'm able to handle the IRQ interrupts under Delphi, using an external VxD which can call my Delphi code as callback function when an interrupt arrives, but I don't know whether the timer works with IRQ, and if so, what IRQ should I handle; I'm also not sure that the Windows 95 will share this IRQ with my VxD.
Waiting for ideas and comments,