Class BoardTimingService
Provides timing, date and delay functions. Also provides access to registered timers.
Namespace: Unosquare.PiGpio.ManagedModel
Syntax
public class BoardTimingService : ITiming
Properties
Epoch
Gets the Linux Epoch (Jan 1, 1970) in UTC.
Declaration
public DateTime Epoch { get; }
Property Value
Type | Description |
---|---|
DateTime |
Microseconds
Declaration
public uint Microseconds { get; }
Property Value
Type | Description |
---|---|
UInt32 |
Milliseconds
Declaration
public uint Milliseconds { get; }
Property Value
Type | Description |
---|---|
UInt32 |
Timestamp
Gets the elapsed time since the Epoc (Jan 1, 1970).
Declaration
public TimeSpan Timestamp { get; }
Property Value
Type | Description |
---|---|
TimeSpan |
TimestampMicroseconds
Gets a timestamp since Jan 1, 1970 in microseconds.
Declaration
public long TimestampMicroseconds { get; }
Property Value
Type | Description |
---|---|
Int64 |
TimestampSeconds
Gets the number of seconds elapsed since the Epoc (Jan 1, 1970).
Declaration
public double TimestampSeconds { get; }
Property Value
Type | Description |
---|---|
Double |
TimestampTick
Gets the timestamp tick. Useful to calculate offsets in Alerts or ISR callbacks.
Declaration
public uint TimestampTick { get; }
Property Value
Type | Description |
---|---|
UInt32 |
Methods
Sleep(Int64)
Sleeps for the specified milliseconds.
Declaration
public void Sleep(long millis)
Parameters
Type | Name | Description |
---|---|---|
Int64 | millis | The milliseconds to sleep for. |
Sleep(TimeSpan)
Sleeps for the specified time span.
Declaration
public void Sleep(TimeSpan timeSpan)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timeSpan | The time span to sleep for. |
SleepMicros(Int64)
Sleeps for the given amount of microseconds. Waits of 100 microseconds or less use busy waits. Returns the real elapsed microseconds.
Declaration
public long SleepMicros(long microsecs)
Parameters
Type | Name | Description |
---|---|---|
Int64 | microsecs | The micro seconds. |
Returns
Type | Description |
---|---|
Int64 | Returns the real elapsed microseconds. |
SleepMicroseconds(UInt32)
Declaration
public void SleepMicroseconds(uint micros)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | micros |
SleepMilliseconds(UInt32)
Declaration
public void SleepMilliseconds(uint millis)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | millis |
StartThread(Action)
Shortcut method to start a thread. It runs the thread automatically.
Declaration
public Thread StartThread(Action doWork)
Parameters
Type | Name | Description |
---|---|---|
Action | doWork | The do work. |
Returns
Type | Description |
---|---|
Thread | A reference to the thread object. |
StartThread(Action, String)
Shortcut method to start a thread. It runs the thread automatically.
Declaration
public Thread StartThread(Action doWork, string threadName)
Parameters
Type | Name | Description |
---|---|---|
Action | doWork | The do work. |
String | threadName | Name of the thread. |
Returns
Type | Description |
---|---|
Thread | A reference to the thread object. |
StartTimer(Int32, Action)
Starts a timer that executes a block of code with the given period.
Declaration
public Timer StartTimer(int periodMilliseconds, Action callback)
Parameters
Type | Name | Description |
---|---|---|
Int32 | periodMilliseconds | The period in milliseconds. |
Action | callback | The callback. |
Returns
Type | Description |
---|---|
Timer | A reference to a timer. |