Difference between revisions of "System.Microseconds"

From Xojo Documentation

 
Line 14: Line 14:
 
''result''='''Microseconds'''
 
''result''='''Microseconds'''
 
{| class="genericTable"
 
{| class="genericTable"
 
 
! width=15% | Part
 
! width=15% | Part
 
 
! width=15% | Type
 
! width=15% | Type
 
 
! width=55% | Description
 
! width=55% | Description
 
|-
 
|-
 
|result
 
|result
 
 
|[[Double]]
 
|[[Double]]
 
|The number of microseconds that have passed since the user's device was started.
 
|The number of microseconds that have passed since the user's device was started.
 
 
|-
 
|-
 
|}
 
|}
Line 34: Line 29:
 
The machine's internal counters might or might not continue to advance while the machine is asleep, or in a similar power-saving mode. Therefore, this function might not be suitable for use as a long-term timer.
 
The machine's internal counters might or might not continue to advance while the machine is asleep, or in a similar power-saving mode. Therefore, this function might not be suitable for use as a long-term timer.
  
==Examples==
+
== Sample Code ==
This example displays in message box the number of minutes the device has been on.
+
This code displays in message box the number of minutes the device has been on:
 
 
 
<rbcode>
 
<rbcode>
 
Var minutes As Integer
 
Var minutes As Integer
Line 42: Line 36:
 
MessageBox("Your device has been on for " + minutes.ToString + " minutes.")
 
MessageBox("Your device has been on for " + minutes.ToString + " minutes.")
 
</rbcode>
 
</rbcode>
 
  
 
[[Category:Language_Date_and_Time]]
 
[[Category:Language_Date_and_Time]]
 
[[Category:API 2.0]]
 
[[Category:API 2.0]]

Latest revision as of 17:09, 11 May 2020

Method

System.Microseconds() As Double

New in 2019r2

Supported for all project types and targets.

Returns the number of microseconds (1,000,000th of a second) that have passed since the user's device was started.

Syntax

result=Microseconds

Part Type Description
result Double The number of microseconds that have passed since the user's device was started.

Notes

Because modern operating systems can stay running for so long, it's possible for the device's internal counters to "roll over." This means that if you are using this function to determine how much time has elapsed, you may encounter a case where this time is inaccurate.

The machine's internal counters might or might not continue to advance while the machine is asleep, or in a similar power-saving mode. Therefore, this function might not be suitable for use as a long-term timer.

Sample Code

This code displays in message box the number of minutes the device has been on:

Var minutes As Integer
minutes = System.Microseconds / 1000000 / 60
MessageBox("Your device has been on for " + minutes.ToString + " minutes.")