1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 10:08:31 +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> /// </summary>
public abstract class AbstractUpdateTrigger : AbstractBindable, IUpdateTrigger public abstract class AbstractUpdateTrigger : AbstractBindable, IUpdateTrigger
{ {
#region Properties & Fields
public abstract double LastUpdateTime { get; protected set; }
#endregion
#region Events #region Events
/// <inheritdoc /> /// <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 AutoResetEvent HasDataEvent { get; set; } = new(false);
protected bool IsRunning { get; set; } protected bool IsRunning { get; set; }
@ -126,9 +128,11 @@ namespace RGB.NET.Core
OnUpdate(); OnUpdate();
double lastUpdateTime = ((Stopwatch.GetTimestamp() - preUpdateTicks) / 10000.0);
LastUpdateTime = lastUpdateTime;
if (UpdateFrequency > 0) if (UpdateFrequency > 0)
{ {
double lastUpdateTime = ((Stopwatch.GetTimestamp() - preUpdateTicks) / 10000.0);
int sleep = (int)((UpdateFrequency * 1000.0) - lastUpdateTime); int sleep = (int)((UpdateFrequency * 1000.0) - lastUpdateTime);
if (sleep > 0) if (sleep > 0)
Thread.Sleep(sleep); Thread.Sleep(sleep);

View File

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

View File

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

View File

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