tags:

views:

32

answers:

2

I want to have something happen about 6 times a second, consistently and accurately. I tried setting an NSTimer, but it had very low accuracy and consistency. What would you recommend?

A: 

Have a look here http://stackoverflow.com/questions/3519562/how-do-i-write-a-timer-in-objective-c it appears that NSTimer is not an high resolution timer

rano
yeah but i need it to fire a selector six times a second. and its not.
marty
you can use those methods to compute a high resolution time difference and after the delta of time is higher of your threshold you can fire your action
rano
well what im actually trying to do is make a strobe light. ive seen other apps do it and just wanted to try it. i duno why but the method that turns the light on and off must be too slow or something because it's very unreliable when i strobe it. i say to call it every .5 seconds and sometimes its on longer than others, sometimes it takes a while to get going, etc.
marty
you shall post some code
rano
A: 

Maybe you want to use ticks instead?

_animationTimer = NSTimer.CreateRepeatingTimer(TimeSpan.FromTicks(Convert.ToInt64(AnimationInterval * 10000000l)), MainLoop);
Fabian Fritz