From 8446b9a47bc567bd919faa6c64add1fff2e35717 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 2 Apr 2017 11:27:24 +0200 Subject: [PATCH] Made surface disposable --- RGB.NET.Core/RGBSurface.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs index f990dcd..c7b664c 100644 --- a/RGB.NET.Core/RGBSurface.cs +++ b/RGB.NET.Core/RGBSurface.cs @@ -11,7 +11,7 @@ namespace RGB.NET.Core /// /// Represents a RGB-surface containing multiple devices. /// - public partial class RGBSurface : AbstractBindable + public partial class RGBSurface : AbstractBindable, IDisposable { #region Properties & Fields @@ -99,6 +99,18 @@ namespace RGB.NET.Core } } + /// + public void Dispose() + { + foreach (IRGBDevice device in _devices) + try { device.Dispose(); } + catch { /* We do what we can */ } + + _ledGroups.Clear(); + _devices = null; + _deviceProvider = null; + } + /// /// Renders a ledgroup. ///