diff --git a/RGB.NET.Core/Groups/AbstractLedGroup.cs b/RGB.NET.Core/Groups/AbstractLedGroup.cs
index 7007152..eab6803 100644
--- a/RGB.NET.Core/Groups/AbstractLedGroup.cs
+++ b/RGB.NET.Core/Groups/AbstractLedGroup.cs
@@ -36,7 +36,7 @@ namespace RGB.NET.Core
#region Methods
///
- public abstract IEnumerable GetLeds();
+ public abstract IList GetLeds();
///
public virtual void OnAttach()
diff --git a/RGB.NET.Core/Groups/ILedGroup.cs b/RGB.NET.Core/Groups/ILedGroup.cs
index 638f146..5db5e63 100644
--- a/RGB.NET.Core/Groups/ILedGroup.cs
+++ b/RGB.NET.Core/Groups/ILedGroup.cs
@@ -25,7 +25,7 @@ namespace RGB.NET.Core
/// Gets a list containing all of this .
///
/// The list containing all of this .
- IEnumerable GetLeds();
+ IList GetLeds();
///
/// Called when the is attached to the .
diff --git a/RGB.NET.Groups/Groups/ListLedGroup.cs b/RGB.NET.Groups/Groups/ListLedGroup.cs
index a5fed36..eb833d8 100644
--- a/RGB.NET.Groups/Groups/ListLedGroup.cs
+++ b/RGB.NET.Groups/Groups/ListLedGroup.cs
@@ -92,9 +92,10 @@ namespace RGB.NET.Groups
{
if (leds == null) return;
- foreach (Led led in leds)
- if ((led != null) && !ContainsLed(led))
- GroupLeds.Add(led);
+ lock (GroupLeds)
+ foreach (Led led in leds)
+ if ((led != null) && !ContainsLed(led))
+ GroupLeds.Add(led);
}
///
@@ -111,9 +112,10 @@ namespace RGB.NET.Groups
{
if (leds == null) return;
- foreach (Led led in leds)
- if (led != null)
- GroupLeds.Remove(led);
+ lock (GroupLeds)
+ foreach (Led led in leds)
+ if (led != null)
+ GroupLeds.Remove(led);
}
///
@@ -121,7 +123,11 @@ namespace RGB.NET.Groups
///
/// The LED which should be checked.
/// true if the LED is contained by this ledgroup; otherwise, false.
- public bool ContainsLed(Led led) => (led != null) && GroupLeds.Contains(led);
+ public bool ContainsLed(Led led)
+ {
+ lock (GroupLeds)
+ return (led != null) && GroupLeds.Contains(led);
+ }
///
/// Merges the from the given ledgroup in this ledgroup.
@@ -129,9 +135,10 @@ namespace RGB.NET.Groups
/// The ledgroup to merge.
public void MergeLeds(ILedGroup groupToMerge)
{
- foreach (Led led in groupToMerge.GetLeds())
- if (!GroupLeds.Contains(led))
- GroupLeds.Add(led);
+ lock (GroupLeds)
+ foreach (Led led in groupToMerge.GetLeds())
+ if (!GroupLeds.Contains(led))
+ GroupLeds.Add(led);
}
///
@@ -139,7 +146,11 @@ namespace RGB.NET.Groups
/// Gets a list containing the from this group.
///
/// The list containing the .
- public override IEnumerable GetLeds() => GroupLeds;
+ public override IList GetLeds()
+ {
+ lock (GroupLeds)
+ return new List(GroupLeds);
+ }
#endregion
}
diff --git a/RGB.NET.Groups/Groups/RectangleLedGroup.cs b/RGB.NET.Groups/Groups/RectangleLedGroup.cs
index 1b23c26..90bb88c 100644
--- a/RGB.NET.Groups/Groups/RectangleLedGroup.cs
+++ b/RGB.NET.Groups/Groups/RectangleLedGroup.cs
@@ -105,7 +105,7 @@ namespace RGB.NET.Groups
/// Gets a list containing all of this .
///
/// The list containing all of this .
- public override IEnumerable GetLeds() => _ledCache ??= RGBSurface.Instance.Leds.Where(led => led.AbsoluteLedRectangle.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList();
+ public override IList GetLeds() => _ledCache ??= RGBSurface.Instance.Leds.Where(led => led.AbsoluteLedRectangle.CalculateIntersectPercentage(Rectangle) >= MinOverlayPercentage).ToList();
private void InvalidateCache() => _ledCache = null;