Monotonous increase in hours in Monotouch

I need to measure elapsed time in several places in my application. Therefore, I am looking for an API that will give me access to monotonically increasing hours, which are not affected by changes in the system clock or daylight saving time (something like the number of milliseconds, since loading will be sufficient).

Sample code to illustrate my problem:

var t1 = SomeClockFunction(); // bunch of code // ... var t2 = SomeClockFunction(); var elapsedTime = t2 - t1; 

I canโ€™t just use the system clock, as this can lead to incorrect measurements if between t1 and t2, the clock is changed by the user or the phone enters / exits summer time.

Objective-C users have access to CACurrentMediaTime () or mach_absolute_time (). What is equivalent in MonoTouch?

+6
source share
3 answers

CAAnimation.CurrentMediaTime ()

+10
source share
+2
source share

http://www.go-mono.com/docs/monodoc.ashx?link=T%3aMonoTouch.Foundation.NSProcessInfo

NSProcessInfo should be supported by MonoTouch, but not documented ... systemUptime should return the absolute time at which the application was launched.

Here's the call in objective-C: (sorry, not familiar with MonoTouch)

 NSTimeInterval interval = [[NSProcessInfo processInfo] systemUptime]; 
+1
source share

All Articles