Share via

Timer Accuracy & Reliability

Nathan Sokalski 4,111 Reputation points
2022-01-11T06:15:04.987+00:00

I need a timer that will execute a piece of code that updates my UI at certain intervals. However, I also need to know when exact 1 second intervals occur. I have heard that if the interval is set to be too frequent, it will sometimes be skipped. My basic goal is to update a clock-like UI, so I need to update the visual circular part at <1 second intervals, but only update the digital part at 1 second intervals. Of the different timers I have been able to find, none of them had a property for the amount of time elapsed since starting it. What would you suggest?

Developer technologies | .NET | Xamarin
0 comments No comments

Answer accepted by question author

JarvanZhang 23,971 Reputation points
2022-01-12T06:15:17.403+00:00

Hello,​

Welcome to our Microsoft Q&A platform!

My basic goal is to update a clock-like UI

Hi, njsokalski. To display a clock-like UI, try using TextClock control. It supports to display the time value and update the value automatically.

   <TextClock  
       android:id="@+id/clock"  
       android:layout_width="match_parent"  
       android:layout_height="wrap_content"  
       android:gravity="center_horizontal"  
       android:format12Hour="dd:MM:yyyy--hh:mm:ss a"/>  

none of them had a property for the amount of time elapsed since starting it. What would you suggest

You could create a parameter to record the start point and then get current time to caculate the the amount of time elapsed.

Best Regards,

Jarvan Zhang


If the response is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.