• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTimer: serious drift in Time (in milliseconds)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTimer: serious drift in Time (in milliseconds)


  • Subject: NSTimer: serious drift in Time (in milliseconds)
  • From: Gilles Celli <email@hidden>
  • Date: Fri, 10 Nov 2006 16:43:08 +0100

Hello,

My app which acquires data every 5 seconds from a Multimeter (via USB port) seems to work fine.
However I remarked that there is a drift (milliseconds) in time when using NSTimer.


The app starts at a given time say 10:00:30,000 (hh:min:sec, millisec) and after 1 hour it loses about >500 millisec, and
finishes with 10:59:59,412.


What can be done to have an exact 5 second time interval ? Is this even possible with NSTimer ?

Maybe a time check with corrections should be done...but this gets complicated
compared to our UNIX based program which acquires exactly at the given time, by using gettimeofday();


Code used:
// This will start the acquisition at 'startDate' (send timed message to self)
timer = [ [[NSTimer alloc] initWithFireDate:startDate
interval:5.0
target:self
selector:@selector (receiveData:)
userInfo:nil
repeats:YES] retain];

[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];



Any infos / suggestions greatly appreciated.

Thanks in advance,

Gilles
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSTimer: serious drift in Time (in milliseconds)
      • From: Andreas Tell <email@hidden>
    • Re: NSTimer: serious drift in Time (in milliseconds)
      • From: Alastair Houghton <email@hidden>
  • Prev by Date: Re: Authorization code fails in Leopard
  • Next by Date: Re: NSTimer: serious drift in Time (in milliseconds)
  • Previous by thread: Re: newbie question
  • Next by thread: Re: NSTimer: serious drift in Time (in milliseconds)
  • Index(es):
    • Date
    • Thread