mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
Fixed tick-resolution issues on linux
This commit is contained in:
parent
105f996729
commit
5b25b10068
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
@ -83,7 +82,7 @@ public static class TimerHelper
|
||||
/// <param name="initialTimestamp">The initial timestamp to calculate the time from.</param>
|
||||
/// <returns>The elapsed time in ms.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static double GetElapsedTime(long initialTimestamp) => ((Stopwatch.GetTimestamp() - initialTimestamp) / (double)TimeSpan.TicksPerMillisecond);
|
||||
public static double GetElapsedTime(long initialTimestamp) => ((Stopwatch.GetTimestamp() - initialTimestamp) / (Stopwatch.Frequency / 1000.0));
|
||||
|
||||
/// <summary>
|
||||
/// Requests to use to use High Resolution Timers if enabled.
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using RGB.NET.Core;
|
||||
@ -14,7 +13,7 @@ public class SteelSeriesDeviceUpdateTrigger : DeviceUpdateTrigger
|
||||
{
|
||||
#region Constants
|
||||
|
||||
private const long FLUSH_TIMER = 5 * 1000 * TimeSpan.TicksPerMillisecond; // flush the device every 5 seconds to prevent timeouts
|
||||
private static readonly long FLUSH_TIMER = 5 * 1000 * (long)(Stopwatch.Frequency / 1000.0); // flush the device every 5 seconds to prevent timeouts
|
||||
|
||||
#endregion
|
||||
|
||||
@ -59,7 +58,7 @@ public class SteelSeriesDeviceUpdateTrigger : DeviceUpdateTrigger
|
||||
|
||||
if (UpdateFrequency > 0)
|
||||
{
|
||||
double lastUpdateTime = ((_lastUpdateTimestamp - preUpdateTicks) / (double)TimeSpan.TicksPerMillisecond);
|
||||
double lastUpdateTime = ((_lastUpdateTimestamp - preUpdateTicks) / (Stopwatch.Frequency / 1000.0));
|
||||
int sleep = (int)((UpdateFrequency * 1000.0) - lastUpdateTime);
|
||||
if (sleep > 0)
|
||||
Thread.Sleep(sleep);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user