|
-
Mar 17th, 2004, 07:52 PM
#1
Thread Starter
Addicted Member
Timers
So I have an app with a timer in it. In the Timer Tick Event I have some code that draws controls to the screen to the beat of a song.
I run my app on one machine, it works great.
I run my app on a different machine, the controls and the beat of the music are way sync.
Why?
Isn't the interval on my timer the same no matter what?
I thought a second was a second???
Very Confused!
-
Mar 18th, 2004, 03:17 PM
#2
Hyperactive Member
Timer's are known for being inacurrate
I haven't heard of it this bad, but it could happen. Look up the get tick count api for accurate measurements of time...
-
Mar 18th, 2004, 03:51 PM
#3
Member
Wow, we just had a talk about this in class today...
Apparantly every CPU counts a tick differently, so whenever you switch machines your timer will be running at a different rate... hence the offbeatedness :/
---Flac
p.s. Im aware that i said absolutly nothing of importance, but im bored, so bare with me.
Everything great once started with the words "That will never catch on, you shouldnt even bother" be great, go against the crowed, do something stupid, you might become famous.
-
Mar 18th, 2004, 04:22 PM
#4
Frenzied Member
so, the project I'm working on won't work.
I am writing a metronome program that allows the user to customize the speed (duh) and the beat sounds (ticks, clicks, dog barks etc)
If timing was an absolute must, couldn't you watch the clock on windows and have an event fire every second of the system clock?
Am I thinking TOO FAR out of the box?
-
Mar 18th, 2004, 06:14 PM
#5
Hyperactive Member
Actually, that is the idea.
Back in QBasic, you used Timer to get the seconds since midnight. How about, you use Timer or parse Time$ in .NET. Then use GetTickCount. Find the number of Ticks in a second. Then base your timing off of this. It should be fairly accurate
-
Mar 18th, 2004, 06:29 PM
#6
Thread Starter
Addicted Member
Well what the hell good are timers if there different on every machine?
Not very good for my app!
-
Mar 18th, 2004, 06:56 PM
#7
Frenzied Member
Have you tried with different timers? I assume you're using the Windows.Forms.Timer which relies on windows messages. The other two timers are System.Timers.Timer and System.Threading.Timer (I think).
There was a good article comparing timers in msdn mag sometime last year - can search on http://msdn.microsoft.com/msdnmag/
HTH,
Mike
-
Mar 18th, 2004, 08:26 PM
#8
Thread Starter
Addicted Member
No I haven't tried that, I'll give it a shot when I get to my comp.
-
Mar 19th, 2004, 08:39 AM
#9
Frenzied Member
Originally posted by Hole-In-One
Well what the hell good are timers if there different on every machine?
Not very good for my app!
guess that's why it's still called visual BASIC lol
I'd say something that needs to be accurate will have to be written
1) in c++ or another language
2) for a dedicated machine that doesn't use the logic that Windows uses.
has anyone tried the other two timers yet?
-
Mar 19th, 2004, 10:28 AM
#10
PowerPoster
Hi Flac,
"p.s. Im aware that i said absolutly nothing of importance, but im bored, so bare with me."
I'm sure we are all ready to BEAR with you, but BARE?? Count me out
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Mar 19th, 2004, 10:47 AM
#11
Frenzied Member
FWIW, I've used all three timers in different applications for different purposes. Have not tried for what Hole-In-One is trying to do.
The Windows.Forms.Timer is the one you usually use for, duh, windows forms. It relies on windows messages, so you can't use it in say, a service application. It is considered the least accurate timer, from what I've read.
The System.Timers.Timer and the System.Threading.Timer provide almost the same functionality, but the threading timer has a cool option to wait for a specified time before the first tick.
When I was writing a service application, I used the timers.timer first, but things were a little flaky. Someone suggested using the threading.timer and that seems to have fixed my problem.
Mike
-
Mar 19th, 2004, 11:43 AM
#12
Frenzied Member
{hmmm.....I wish I was bare right now....}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|