Added new steelseries device-zones; prevent update-spam in steelseries updatetrigger

This commit is contained in:
DarthAffe committed 2019-11-24 16:30:38 +01:00
1 parent 3ecf737add
commit 50532637ab
3 files changed
+209 -4

No files matched your search

@@ -29,7 +29,6 @@ namespace RGB.NET.Devices.SteelSeries
/// <summary>
/// Initializes a new instance of the <see cref="SteelSeriesDeviceUpdateTrigger"/> class.
/// </summary>
/// <param name="updateRateHardLimit">The hard limit of the update rate of this trigger.</param>
public SteelSeriesDeviceUpdateTrigger()
{ }
@@ -45,9 +44,11 @@ namespace RGB.NET.Devices.SteelSeries
#region Methods
/// <inheritdoc />
protected override void UpdateLoop()
{
OnStartup();
while (!UpdateToken.IsCancellationRequested)
{
if (HasDataEvent.WaitOne(Timeout))
@@ -58,18 +59,24 @@ namespace RGB.NET.Devices.SteelSeries
if (UpdateFrequency > 0)
{
_lastUpdateTimestamp = Stopwatch.GetTimestamp();
double lastUpdateTime = ((_lastUpdateTimestamp - preUpdateTicks) / (double)TimeSpan.TicksPerMillisecond);
int sleep = (int)((UpdateFrequency * 1000.0) - lastUpdateTime);
if (sleep > 0)
Thread.Sleep(sleep);
}
}
else if (((Stopwatch.GetTimestamp() - _lastUpdateTimestamp) > FLUSH_TIMER))
else if ((_lastUpdateTimestamp > 0) && ((Stopwatch.GetTimestamp() - _lastUpdateTimestamp) > FLUSH_TIMER))
OnUpdate(new CustomUpdateData(("refresh", true)));
}
}
/// <inheritdoc />
protected override void OnUpdate(CustomUpdateData updateData = null)
{
base.OnUpdate(updateData);
_lastUpdateTimestamp = Stopwatch.GetTimestamp();
}
#endregion
}
}