From d090ab0085983aff83f4e8da92dbd9ef11e6783d Mon Sep 17 00:00:00 2001 From: Austin Noska Date: Wed, 20 Jan 2021 17:46:26 -0500 Subject: [PATCH 1/3] fix: The SafeTimer constructor that executes the callback immediately now works as expected --- CHANGELOG.md | 3 +++ .../Services/Scheduler/ActionSchedulerService.cs | 11 +---------- ICD.Common.Utils/Timers/SafeTimer.cs | 4 ++-- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d981b..852bee7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Changed + - A SafeTimer constructor that executes the callback immediately now does this instead of waiting infinitely + ## [14.0.0] - 2021-01-14 ### Added - Added Get and Set extensions to PropertyInfo in SIMPLSHARP to mimic overloads avaliable in NETSTANDARD diff --git a/ICD.Common.Utils/Services/Scheduler/ActionSchedulerService.cs b/ICD.Common.Utils/Services/Scheduler/ActionSchedulerService.cs index 868eee1..dd65352 100644 --- a/ICD.Common.Utils/Services/Scheduler/ActionSchedulerService.cs +++ b/ICD.Common.Utils/Services/Scheduler/ActionSchedulerService.cs @@ -18,9 +18,9 @@ namespace ICD.Common.Utils.Services.Scheduler public ActionSchedulerService() { m_Actions = new List(); - m_Timer = new SafeTimer(TimerCallback, -1); m_CriticalSection = new SafeCriticalSection(); m_LastRunTime = DateTime.MinValue; + m_Timer = SafeTimer.Stopped(TimerCallback); } public void Dispose() @@ -153,15 +153,6 @@ namespace ICD.Common.Utils.Services.Scheduler } } - private void Log(eSeverity severity, string message, params object[] args) - { - ILoggerService logger = ServiceProvider.TryGetService(); - if (logger == null) - return; - - logger.AddEntry(severity, string.Format("{0} - {1}", this, message), args); - } - private void Log(eSeverity severity, Exception ex, string message, params object[] args) { ILoggerService logger = ServiceProvider.TryGetService(); diff --git a/ICD.Common.Utils/Timers/SafeTimer.cs b/ICD.Common.Utils/Timers/SafeTimer.cs index 254b42d..3bc3db2 100644 --- a/ICD.Common.Utils/Timers/SafeTimer.cs +++ b/ICD.Common.Utils/Timers/SafeTimer.cs @@ -36,7 +36,7 @@ namespace ICD.Common.Utils.Timers /// /// public SafeTimer(Action callback, long repeatPeriod) - : this(callback, -1, repeatPeriod) + : this(callback, 0, repeatPeriod) { } @@ -138,7 +138,7 @@ namespace ICD.Common.Utils.Timers if (repeatPeriod < 0 && repeatPeriod != Timeout.Infinite) throw new ArgumentOutOfRangeException("repeatPeriod", "Repeat period must be greater than or equal to 0ms"); - if (dueTime >= int.MaxValue) + if (repeatPeriod >= int.MaxValue) throw new ArgumentOutOfRangeException("repeatPeriod", string.Format("Repeat period must be less than {0:n0}ms", int.MaxValue)); #if SIMPLSHARP From 45a3c5c5a1fae30941510d7d51de0cee8c284454 Mon Sep 17 00:00:00 2001 From: Austin Noska Date: Tue, 19 Jan 2021 15:52:50 -0500 Subject: [PATCH 2/3] feat: Add overload to GuidUtils to combine an IEnumerable of guids into a new deterministic guid --- CHANGELOG.md | 2 ++ ICD.Common.Utils/GuidUtils.cs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 852bee7..bd0960e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added + - Added overload to GuidUtils that takes an enumerable of guids and combines them into a new deterministic guid ### Changed - A SafeTimer constructor that executes the callback immediately now does this instead of waiting infinitely diff --git a/ICD.Common.Utils/GuidUtils.cs b/ICD.Common.Utils/GuidUtils.cs index 045c9fa..9edcc31 100644 --- a/ICD.Common.Utils/GuidUtils.cs +++ b/ICD.Common.Utils/GuidUtils.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using ICD.Common.Utils.Extensions; namespace ICD.Common.Utils { @@ -30,5 +32,13 @@ namespace ICD.Common.Utils return new Guid(aBytes); } + + /// + /// Combines the guids in the given order to make a new, deterministic guid. + /// + public static Guid Combine(IEnumerable guids) + { + return guids.AggregateOrDefault(Combine, default(Guid)); + } } } From d7bee510c9df8de413a4e25e305cd4434f348ad6 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Thu, 21 Jan 2021 10:40:26 -0500 Subject: [PATCH 3/3] chore: Update changelog, increment minor version --- CHANGELOG.md | 2 ++ ICD.Common.Utils/Properties/AssemblyInfo.cs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd0960e..5b3de80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## [14.1.0] - 2021-01-21 ### Added - Added overload to GuidUtils that takes an enumerable of guids and combines them into a new deterministic guid diff --git a/ICD.Common.Utils/Properties/AssemblyInfo.cs b/ICD.Common.Utils/Properties/AssemblyInfo.cs index a8f68e5..8d23892 100644 --- a/ICD.Common.Utils/Properties/AssemblyInfo.cs +++ b/ICD.Common.Utils/Properties/AssemblyInfo.cs @@ -4,4 +4,4 @@ using System.Reflection; [assembly: AssemblyCompany("ICD Systems")] [assembly: AssemblyProduct("ICD.Common.Utils")] [assembly: AssemblyCopyright("Copyright © ICD Systems 2021")] -[assembly: AssemblyVersion("14.0.0.0")] +[assembly: AssemblyVersion("14.1.0.0")]