Thread View: comp.os.ms-windows.programmer.win32
4 messages
4 total messages
Started by Robin Burrows
Tue, 06 Oct 1998 00:00
SetTimer
Author: Robin Burrows
Date: Tue, 06 Oct 1998 00:00
Date: Tue, 06 Oct 1998 00:00
11 lines
1154 bytes
1154 bytes
Hello, I'm trying to set up a timer with the following line: SetTimer (hwnd, 1, 1000/30, NULL); (30 interrupts per second) but the interval is nothing like that. For example, I process 90 interrupts which should take 3 seconds, but it takes more like 15. I am using a fprintf in my WM_TIMER, but the file remains open so the buffering should absorb it, there is no other lengthy code in there. What is the minimum gap between interrupts? Or am I just being dense? Do I really have to use GetTickCount and compensate for it myself?
Re: SetTimer
Author: Christopher J. Black
Date: Tue, 06 Oct 1998 00:00
Date: Tue, 06 Oct 1998 00:00
25 lines
1683 bytes
1683 bytes
Read the doco ... SetTimer only has 55ms resolution (rounded up) so (int)(1000/30) = 33 , which becomes 55ms which means if the WM_TIMER message is never left in the queue then 90 WM_TIMER msgs will take approx. 5 sec. These are *not* real time OSs. You should always check clock-ticks if accuracy is important. If you really require 33 ms timers use multi-media timers, they can trigger at 1ms intervals (but have associated overheads). Good Luck ChrisB2 Robin Burrows wrote in message <3619553C.11D5@bigfoot.com>... >Hello, > >I'm trying to set up a timer with the following line: >SetTimer (hwnd, 1, 1000/30, NULL); >(30 interrupts per second) but the interval is nothing like that. For >example, I process 90 interrupts which should take 3 seconds, but it >takes more like 15. I am using a fprintf in my WM_TIMER, but the file >remains open so the buffering should absorb it, there is no other >lengthy code in there. What is the minimum gap between interrupts? Or am >I just being dense? Do I really have to use GetTickCount and compensate >for it myself? >
Re: SetTimer
Author: Brett g Porter
Date: Tue, 06 Oct 1998 00:00
Date: Tue, 06 Oct 1998 00:00
30 lines
1924 bytes
1924 bytes
A couple of things: 1) The standard timer is driven by the standard BIOS timer tick, so you can't generate more than 18.2 timer events per second using SetTimer. To go faster, you'll have to use the multimedia timers (see the timeSet* functions, etc.) 2)If the timer generates another tick before your app has processed the last WM_TIMER message, it will NOT put another one on the queue. Also, WM_TIMER messages are low priority, and will only be given to your app if there are no other messages on the queue. -- // // reply to: // BgPorter at acm dot org // Robin Burrows wrote in message <3619553C.11D5@bigfoot.com>... >Hello, > >I'm trying to set up a timer with the following line: >SetTimer (hwnd, 1, 1000/30, NULL); >(30 interrupts per second) but the interval is nothing like that. For >example, I process 90 interrupts which should take 3 seconds, but it >takes more like 15. I am using a fprintf in my WM_TIMER, but the file >remains open so the buffering should absorb it, there is no other >lengthy code in there. What is the minimum gap between interrupts? Or am >I just being dense? Do I really have to use GetTickCount and compensate >for it myself? >
Re: SetTimer
Author: Joris Van Damme
Date: Tue, 06 Oct 1998 00:00
Date: Tue, 06 Oct 1998 00:00
25 lines
1652 bytes
1652 bytes
Robin Burrows wrote: > I am using a fprintf in my WM_TIMER, but the file > remains open so the buffering should absorb it, there is no other > lengthy code in there. What is the minimum gap between interrupts? Or am > I just being dense? Do I really have to use GetTickCount and compensate > for it myself? Greetings. I share the opinions of the people who already responded. I'ld like to add though that I find this a strange way to print. Probably your concern is to to not block the main thread - which would result in 'blank' pieces of screen waiting to be updated during the printing process, and the user would not be able to do anything. There are several other, proper, ways to take case of this. Do the printing in another thread. This is by far the best way, but also not very easy if you didn't do this before. The ProcessMessages is a far easier way out: encapsulate the timer code in in a loop, and do a ProcessMessages after each loop. Joris Van Damme ecogreen.joris.vandamme@ping.be
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads