diff --git a/RGB.NET.Core/Groups/ListLedGroup.cs b/RGB.NET.Core/Groups/ListLedGroup.cs
index c6f7d54..a97b6ec 100644
--- a/RGB.NET.Core/Groups/ListLedGroup.cs
+++ b/RGB.NET.Core/Groups/ListLedGroup.cs
@@ -15,6 +15,8 @@ public class ListLedGroup : AbstractLedGroup
{
#region Properties & Fields
+ private readonly ActionDisposable _unlockDisposable;
+
///
/// Gets the list containing the of this .
///
@@ -31,7 +33,9 @@ public class ListLedGroup : AbstractLedGroup
/// Specifies the surface to attach this group to or null if the group should not be attached on creation.
public ListLedGroup(RGBSurface? surface)
: base(surface)
- { }
+ {
+ _unlockDisposable = new ActionDisposable(Unlock);
+ }
///
///
@@ -42,6 +46,8 @@ public class ListLedGroup : AbstractLedGroup
public ListLedGroup(RGBSurface? surface, IEnumerable leds)
: base(surface)
{
+ _unlockDisposable = new ActionDisposable(Unlock);
+
AddLeds(leds);
}
@@ -54,6 +60,8 @@ public class ListLedGroup : AbstractLedGroup
public ListLedGroup(RGBSurface? surface, params Led[] leds)
: base(surface)
{
+ _unlockDisposable = new ActionDisposable(Unlock);
+
AddLeds(leds);
}
@@ -141,8 +149,10 @@ public class ListLedGroup : AbstractLedGroup
{
Monitor.Enter(GroupLeds);
leds = GroupLeds;
- return new ActionDisposable(() => Monitor.Exit(GroupLeds));
+ return _unlockDisposable;
}
+ private void Unlock() => Monitor.Exit(GroupLeds);
+
#endregion
}
\ No newline at end of file
diff --git a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs
index db22aa4..00abcc7 100644
--- a/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs
+++ b/RGB.NET.Core/Update/Devices/DeviceUpdateTrigger.cs
@@ -157,11 +157,13 @@ public class DeviceUpdateTrigger : AbstractUpdateTrigger, IDeviceUpdateTrigger
using (TimerHelper.RequestHighResolutionTimer())
while (!UpdateToken.IsCancellationRequested)
if (HasDataEvent.WaitOne(Timeout))
- LastUpdateTime = TimerHelper.Execute(() => OnUpdate(), UpdateFrequency * 1000);
+ LastUpdateTime = TimerHelper.Execute(TimerExecute, UpdateFrequency * 1000);
else if ((HeartbeatTimer > 0) && (LastUpdateTimestamp > 0) && (TimerHelper.GetElapsedTime(LastUpdateTimestamp) > HeartbeatTimer))
OnUpdate(new CustomUpdateData().Heartbeat());
}
+ private void TimerExecute() => OnUpdate();
+
protected override void OnUpdate(CustomUpdateData? updateData = null)
{
base.OnUpdate(updateData);
diff --git a/RGB.NET.Core/Update/ManualUpdateTrigger.cs b/RGB.NET.Core/Update/ManualUpdateTrigger.cs
index 67e8ca4..5cd4235 100644
--- a/RGB.NET.Core/Update/ManualUpdateTrigger.cs
+++ b/RGB.NET.Core/Update/ManualUpdateTrigger.cs
@@ -83,12 +83,12 @@ public sealed class ManualUpdateTrigger : AbstractUpdateTrigger
OnStartup();
while (!UpdateToken.IsCancellationRequested)
- {
if (_mutex.WaitOne(100))
- LastUpdateTime = TimerHelper.Execute(() => OnUpdate(_customUpdateData));
- }
+ LastUpdateTime = TimerHelper.Execute(TimerExecute);
}
+ private void TimerExecute() => OnUpdate(_customUpdateData);
+
///
public override void Dispose() => Stop();
diff --git a/RGB.NET.Core/Update/TimerUpdateTrigger.cs b/RGB.NET.Core/Update/TimerUpdateTrigger.cs
index 14a7e9f..9f2b2b6 100644
--- a/RGB.NET.Core/Update/TimerUpdateTrigger.cs
+++ b/RGB.NET.Core/Update/TimerUpdateTrigger.cs
@@ -131,10 +131,11 @@ public class TimerUpdateTrigger : AbstractUpdateTrigger
using (TimerHelper.RequestHighResolutionTimer())
while (!UpdateToken.IsCancellationRequested)
- LastUpdateTime = TimerHelper.Execute(() => OnUpdate(_customUpdateData), UpdateFrequency * 1000);
-
+ LastUpdateTime = TimerHelper.Execute(TimerExecute, UpdateFrequency * 1000);
}
+ private void TimerExecute() => OnUpdate(_customUpdateData);
+
///
public override void Dispose()
{
diff --git a/RGB.NET.Presets/Groups/RectangleLedGroup.cs b/RGB.NET.Presets/Groups/RectangleLedGroup.cs
index d6cb650..cf66848 100644
--- a/RGB.NET.Presets/Groups/RectangleLedGroup.cs
+++ b/RGB.NET.Presets/Groups/RectangleLedGroup.cs
@@ -2,6 +2,7 @@
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
// ReSharper disable UnusedMember.Global
+using System;
using System.Collections.Generic;
using System.Linq;
using RGB.NET.Core;
@@ -121,7 +122,7 @@ public class RectangleLedGroup : AbstractLedGroup
/// Gets a list containing all of this .
///
/// The list containing all of this .
- public override IList ToList() => _ledCache ??= (Surface?.Leds.Where(led => led.AbsoluteBoundary.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList() ?? new List());
+ public override IList ToList() => _ledCache ??= ((IList?)Surface?.Leds.Where(led => led.AbsoluteBoundary.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList() ?? Array.Empty());
private void InvalidateCache() => _ledCache = null;