Alvin Stefanus
Alvin Stefanus

Reputation: 2153

C# Xamarin IOS: Equivalent of SystemClock.ElapsedRealtime() in C# IOS Xamarin

I need to keep the time since the application has started. The time needs to be keep ticking even though the device went to sleep mode.

In Android there is SystemClock.ElapsedRealtime() which keeps ticking on sleep.

In IOS there is NSProcessInfo.processInfo().systemUptime but this will stop ticking when the device went to sleep mode.

I saw many implementations using some kernel timer but they are all written on Objective-C or Swift. I need to use the Xamarin cross platform library, which I do not know how to convert those code into C#.

Upvotes: 0

Views: 1069

Answers (1)

Gwen Royakkers
Gwen Royakkers

Reputation: 441

Is it an option to store the current time when the app starts. And when you need to know the time interval, subtract the stored time from the current time?

This will work if no event logic is required during sleep.

Upvotes: 1

Related Questions