Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Updates documentation of Device.StartTimer (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
michizhou authored and samhouts committed Dec 5, 2019
1 parent 236e0ac commit c8b97b9
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions docs/Xamarin.Forms/Device.xml
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,24 @@ button.HeightRequest = Device.OnPlatform (20,30,30);
<Docs>
<param name="interval">The interval between invocations of the callback.</param>
<param name="callback">The action to run when the timer elapses.</param>
<summary>Starts a recurring timer on the UI thread using the device clock capabilities.</summary>
<remarks>While the callback returns <see langword="true" />, the timer will keep recurring.</remarks>
<summary>Starts a recurring timer using the device clock capabilities.</summary>
<remarks>
<para>While the callback returns <see langword="true" />, the timer will keep recurring.</para>
<para>If you want the code inside the timer to interact on the UI thread (e.g. setting text of a Label or showing an alert), it should be done within a <see langword="BeginInvokeOnMainThread" /> expression, which will be nested inside the timer (see below).</para>
<example>
<code lang="csharp lang-csharp"><![CDATA[
Device.StartTimer (new TimeSpan (0, 0, 60), () =>
{
// do something every 60 seconds
Device.BeginInvokeOnMainThread (() =>
{
// interact with UI elements
});
return true; // runs again, or false to stop
});
]]></code>
</example>
</remarks>
</Docs>
</Member>
<Member MemberName="Tizen">
Expand Down

0 comments on commit c8b97b9

Please sign in to comment.