1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 01:58:30 +00:00

Added missing provider-init-changes to CorsairLegacy

This commit is contained in:
Darth Affe 2023-08-16 21:47:54 +02:00
parent 4209905474
commit 2c8bc72dc9

View File

@ -18,11 +18,21 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider
{ {
#region Properties & Fields #region Properties & Fields
// ReSharper disable once InconsistentNaming
private static readonly object _lock = new();
private static CorsairLegacyDeviceProvider? _instance; private static CorsairLegacyDeviceProvider? _instance;
/// <summary> /// <summary>
/// Gets the singleton <see cref="CorsairLegacyDeviceProvider"/> instance. /// Gets the singleton <see cref="CorsairLegacyDeviceProvider"/> instance.
/// </summary> /// </summary>
public static CorsairLegacyDeviceProvider Instance => _instance ?? new CorsairLegacyDeviceProvider(); public static CorsairLegacyDeviceProvider Instance
{
get
{
lock (_lock)
return _instance ?? new CorsairLegacyDeviceProvider();
}
}
/// <summary> /// <summary>
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications. /// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
@ -55,10 +65,13 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider
/// </summary> /// </summary>
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception> /// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
public CorsairLegacyDeviceProvider() public CorsairLegacyDeviceProvider()
{
lock (_lock)
{ {
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairLegacyDeviceProvider)}"); if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairLegacyDeviceProvider)}");
_instance = this; _instance = this;
} }
}
#endregion #endregion
@ -201,12 +214,17 @@ public sealed class CorsairLegacyDeviceProvider : AbstractRGBDeviceProvider
} }
/// <inheritdoc /> /// <inheritdoc />
public override void Dispose() protected override void Dispose(bool disposing)
{ {
base.Dispose(); lock (_lock)
{
base.Dispose(disposing);
try { _CUESDK.UnloadCUESDK(); } try { _CUESDK.UnloadCUESDK(); }
catch { /* at least we tried */ } catch { /* at least we tried */ }
_instance = null;
}
} }
#endregion #endregion