From 877c65470296a3fb3cd48faf7de5bfcce48eeba7 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 11 Dec 2017 09:44:57 +0100 Subject: [PATCH] Added property to the surface to get the last update-time --- RGB.NET.Core/RGBSurfaceUpdater.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/RGB.NET.Core/RGBSurfaceUpdater.cs b/RGB.NET.Core/RGBSurfaceUpdater.cs index a7d83cb..6582822 100644 --- a/RGB.NET.Core/RGBSurfaceUpdater.cs +++ b/RGB.NET.Core/RGBSurfaceUpdater.cs @@ -24,6 +24,11 @@ namespace RGB.NET.Core set => SetProperty(ref _updateFrequency, value); } + /// + /// Gets the time it took the last update-loop cycle to run. + /// + public double LastUpdateTime { get; private set; } + private UpdateMode _updateMode = UpdateMode.Manual; /// /// Gets or sets the update-mode. @@ -85,7 +90,8 @@ namespace RGB.NET.Core Update(); - int sleep = (int)((UpdateFrequency * 1000.0) - ((DateTime.Now.Ticks - preUpdateTicks) / 10000.0)); + LastUpdateTime = ((DateTime.Now.Ticks - preUpdateTicks) / 10000.0); + int sleep = (int)((UpdateFrequency * 1000.0) - LastUpdateTime); if (sleep > 0) Thread.Sleep(sleep); }