Skip to content

Commit 320a08c

Browse files
author
Eric Bézine
committed
Do not use high resolution timer if delay > 100ms
1 parent 3459139 commit 320a08c

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Raspberry.System/Timers/HighResolutionTimer.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
namespace Raspberry.Timers
99
{
10+
/// <summary>
11+
/// Represents a high-resolution timer.
12+
/// </summary>
1013
public class HighResolutionTimer : ITimer
1114
{
1215
#region Fields
@@ -71,6 +74,18 @@ public Action Action
7174

7275
#region Methods
7376

77+
/// <summary>
78+
/// Sleeps the specified delay.
79+
/// </summary>
80+
/// <param name="delay">The delay.</param>
81+
public static void Sleep(decimal delay)
82+
{
83+
if (delay >= 100)
84+
Thread.Sleep((int)delay);
85+
else
86+
Interop.bcm2835_delayMicroseconds((uint)(delay * 1000));
87+
}
88+
7489
/// <summary>
7590
/// Starts this instance.
7691
/// </summary>
@@ -125,11 +140,6 @@ private void ThreadProcess()
125140

126141
private void NoOp(){}
127142

128-
public static void Sleep(decimal delay)
129-
{
130-
Interop.bcm2835_delayMicroseconds((uint) (delay*1000));
131-
}
132-
133143
#endregion
134144
}
135145
}

0 commit comments

Comments
 (0)