A problem with the Timer component
Author |
Message |
Radu Stanci #1 / 7
|
 A problem with the Timer component
Hi, I have just noticed a problem with the Timer control. I've set the interval to 1000 miliseconds, and I use it to count the time I stay online. Windows also displays an icon in the syste tray about the current connection. The problem is, after a time some differences appear between the two times. It appears that the Timer is not always executed every second. What can I do about this? Is this a bug? Is there a way to get the connect speed directly from the Windows DUN timer? Thanks. Radu
|
Tue, 22 Jan 2002 03:00:00 GMT |
|
 |
Stoil Marino #2 / 7
|
 A problem with the Timer component
Hi Radu, The time resolution of this Timer is about ~55 ms, so you have no reason to expect them to fire precisely every 1000 ms. Moreover, you cannot expect it to fire each time the interval expires. When you enable the Timer, what happens is, that the system is instructed to send your app WM_TIMER messages at the intervals set. But if something is blocking your app from processing its message queue, no Timer events are fired. And if the blocking continues for longer (e.g. several Timer intervals) you will lose some of the WM_TIMER messages because the system does not stack them, much like with the WM_PAINT message. So, that is why it is bad idea to measure the time elapsed by counting the Timer events. What you need to do is save the start time in a variable and in the Timer event get the current system time (Now) and use the DateDiff() function to find the difference between the two. This will give you the correct value each time. Regards, Stoil Quote:
> Hi, > I have just noticed a problem with the Timer control. I've set the interval to 1000 miliseconds, and I use it to count the time I stay online. Windows also displays an icon in the syste tray about the current connection. The problem is, after a time some differences appear between the two times. It appears that the Timer is not always executed every second. What can I do about this? Is this a bug? Is there a way to get the connect speed directly from the Windows DUN timer? Thanks. > Radu
|
Tue, 22 Jan 2002 03:00:00 GMT |
|
 |
e-mal #3 / 7
|
 A problem with the Timer component
I had the same problem, check the thread VB's 58 second, in microsoft.public.vb.syntax I have just finished my program that does just what you are seeking to do. does it time, or time and cost too ? Graham.
Quote: > Hi Radu, > The time resolution of this Timer is about ~55 ms, so you have no reason > to expect them to fire precisely every 1000 ms. Moreover, you cannot > expect it to fire each time the interval expires. When you enable the > Timer, what happens is, that the system is instructed to send your app > WM_TIMER messages at the intervals set. But if something is blocking > your app from processing its message queue, no Timer events are fired. > And if the blocking continues for longer (e.g. several Timer intervals) > you will lose some of the WM_TIMER messages because the system does not > stack them, much like with the WM_PAINT message. > So, that is why it is bad idea to measure the time elapsed by counting > the Timer events. What you need to do is save the start time in a > variable and in the Timer event get the current system time (Now) and > use the DateDiff() function to find the difference between the two. This > will give you the correct value each time. > Regards, > Stoil
> > Hi, > > I have just noticed a problem with the Timer control. I've set the
interval to 1000 miliseconds, and I use it to count the time I stay online. Windows also displays an icon in the syste tray about the current connection. The problem is, after a time some differences appear between the two times. It appears that the Timer is not always executed every second. What can I do about this? Is this a bug? Is there a way to get the connect speed directly from the Windows DUN timer? Thanks. Quote:
|
Fri, 25 Jan 2002 03:00:00 GMT |
|
 |
Radu Stanci #4 / 7
|
 A problem with the Timer component
Hi, Thanks for directing me to the thread in the syntax newsgroup. Jeff told me almost the same thing in here, and I got it to work. My program only counts the time you stay connected. Here in Romania (I also have to pay the time I stay connected to my ISP) there are only three intervals each day (we don't have special taxes for week-ends or something like this), so it wouldn't be hard to calculate the connection cost, but I simply didn't want to do this.
--
Outlook Express Unofficial Site: http://www.outlookexpress.go.ro VB Open Source Site: http://open-source.home.ro Visit http://www.eclipsa99.ro and see the eclipse filmed live from Romania on August 11, 1999. Quote:
> I had the same problem, check the thread > VB's 58 second, > in microsoft.public.vb.syntax > I have just finished my program that does just what you are seeking to do. > does it time, or time and cost too ? > Graham.
> > Hi Radu, > > The time resolution of this Timer is about ~55 ms, so you have no reason > > to expect them to fire precisely every 1000 ms. Moreover, you cannot > > expect it to fire each time the interval expires. When you enable the > > Timer, what happens is, that the system is instructed to send your app > > WM_TIMER messages at the intervals set. But if something is blocking > > your app from processing its message queue, no Timer events are fired. > > And if the blocking continues for longer (e.g. several Timer intervals) > > you will lose some of the WM_TIMER messages because the system does not > > stack them, much like with the WM_PAINT message. > > So, that is why it is bad idea to measure the time elapsed by counting > > the Timer events. What you need to do is save the start time in a > > variable and in the Timer event get the current system time (Now) and > > use the DateDiff() function to find the difference between the two. This > > will give you the correct value each time. > > Regards, > > Stoil
> > > Hi, > > > I have just noticed a problem with the Timer control. I've set the > interval to 1000 miliseconds, and I use it to count the time I stay online. > Windows also displays an icon in the syste tray about the current > connection. The problem is, after a time some differences appear between the > two times. It appears that the Timer is not always executed every second. > What can I do about this? Is this a bug? Is there a way to get the connect > speed directly from the Windows DUN timer? Thanks. > > > Radu
|
Sat, 26 Jan 2002 03:00:00 GMT |
|
 |
Farshad Hemmat #5 / 7
|
 A problem with the Timer component
Your problem is not only with your system. Their will be a huger difference if you run the same program on Windows NT. Each operating system has a different update frequency. Windows NT updates a lot faster so if you are going to do animation you will see it go 2 to 4 times faster. Best Solution:---------------- Multimedia Timer Where:-------------------- http://www.vbaccelerator.com It is precise and won't have differences between different computers or OS's either. -- Thank You, Farshad Hemmati Microsoft Visual Basic MVP CompuCated Technologies http://www.compucated.com/
Hi, I have just noticed a problem with the Timer control. I've set the interval to 1000 miliseconds, and I use it to count the time I stay online. Windows also displays an icon in the syste tray about the current connection. The problem is, after a time some differences appear between the two times. It appears that the Timer is not always executed every second. What can I do about this? Is this a bug? Is there a way to get the connect speed directly from the Windows DUN timer? Thanks. Radu
|
Mon, 28 Jan 2002 03:00:00 GMT |
|
 |
boychen #6 / 7
|
 A problem with the Timer component
I know that win95/98 update the timer once every 1/18.7 second -- boycheng, KTMC <Remove all H to reply>NOSPAM!
|
Thu, 31 Jan 2002 03:00:00 GMT |
|
 |
<jka.. #7 / 7
|
 A problem with the Timer component
Why not use the GetTickCount API function. If you don't use your timer to trigger events then this method is much simpler. GetTickCount returns the number of milliseconds since the system was booted. I doubt that this would be affecfted by clock update speed. Declare Sub GetTickCount& Lib "kernel32" () Good Luck! Jeff Kanel Quote:
>Your problem is not only with your system. Their will be a huger difference >if you run the same program on Windows NT. Each operating system has a >different update frequency. Windows NT updates a lot faster so if you are >going to do animation you will see it go 2 to 4 times faster. >Best Solution:---------------- >Multimedia Timer >Where:-------------------- >http://www.vbaccelerator.com >It is precise and won't have differences between different computers or OS's >either. >-- >Thank You, >Farshad Hemmati >Microsoft Visual Basic MVP >CompuCated Technologies >http://www.compucated.com/
>Hi, >I have just noticed a problem with the Timer control. I've set the interval >to 1000 miliseconds, and I use it to count the time I stay online. Windows >also displays an icon in the syste tray about the current connection. The >problem is, after a time some differences appear between the two times. It >appears that the Timer is not always executed every second. What can I do >about this? Is this a bug? Is there a way to get the connect speed directly >from the Windows DUN timer? Thanks. >Radu
|
Sun, 03 Feb 2002 03:00:00 GMT |
|
|
|