1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 01:58:30 +00:00

Added LastUpdateTime to update-triggers

This commit is contained in:
Darth Affe 2021-04-24 20:39:05 +02:00
parent 41edda99f0
commit a1955ec377
5 changed files with 15 additions and 3 deletions

View File

@ -7,6 +7,12 @@ namespace RGB.NET.Core
/// </summary>
public abstract class AbstractUpdateTrigger : AbstractBindable, IUpdateTrigger
{
#region Properties & Fields
public abstract double LastUpdateTime { get; protected set; }
#endregion
#region Events
/// <inheritdoc />

View File

@ -53,6 +53,8 @@ namespace RGB.NET.Core
}
}
public override double LastUpdateTime { get; protected set; }
protected AutoResetEvent HasDataEvent { get; set; } = new(false);
protected bool IsRunning { get; set; }
@ -126,9 +128,11 @@ namespace RGB.NET.Core
OnUpdate();
double lastUpdateTime = ((Stopwatch.GetTimestamp() - preUpdateTicks) / 10000.0);
LastUpdateTime = lastUpdateTime;
if (UpdateFrequency > 0)
{
double lastUpdateTime = ((Stopwatch.GetTimestamp() - preUpdateTicks) / 10000.0);
int sleep = (int)((UpdateFrequency * 1000.0) - lastUpdateTime);
if (sleep > 0)
Thread.Sleep(sleep);

View File

@ -7,6 +7,8 @@ namespace RGB.NET.Core
/// </summary>
public interface IUpdateTrigger : IDisposable
{
double LastUpdateTime { get; }
/// <summary>
/// Occurs when the trigger is starting up.
/// </summary>

View File

@ -22,7 +22,7 @@ namespace RGB.NET.Core
/// <summary>
/// Gets the time it took the last update-loop cycle to run.
/// </summary>
public double LastUpdateTime { get; private set; }
public override double LastUpdateTime { get; protected set; }
#endregion

View File

@ -33,7 +33,7 @@ namespace RGB.NET.Core
/// <summary>
/// Gets the time it took the last update-loop cycle to run.
/// </summary>
public double LastUpdateTime { get; private set; }
public override double LastUpdateTime { get; protected set; }
#endregion