mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-13 10:08:31 +00:00
Added locks around device provider instance usages
This commit is contained in:
parent
fdc69fdac5
commit
0609e49571
@ -16,11 +16,21 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static AsusDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="AsusDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static AsusDeviceProvider Instance => _instance ?? new AsusDeviceProvider();
|
||||
public static AsusDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new AsusDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
private IAuraSdk2? _sdk;
|
||||
private IAuraSyncDeviceCollection? _devices; //HACK DarthAffe 05.04.2021: Due to some researches this might fix the access violation in the asus-sdk
|
||||
@ -34,10 +44,13 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public AsusDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(AsusDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -81,6 +94,8 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
@ -91,6 +106,7 @@ public sealed class AsusDeviceProvider : AbstractRGBDeviceProvider
|
||||
_sdk = null;
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -17,11 +17,21 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static CoolerMasterDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="CoolerMasterDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static CoolerMasterDeviceProvider Instance => _instance ?? new CoolerMasterDeviceProvider();
|
||||
public static CoolerMasterDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new CoolerMasterDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
@ -44,10 +54,13 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public CoolerMasterDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CoolerMasterDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -95,6 +108,8 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
@ -103,6 +118,7 @@ public sealed class CoolerMasterDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -17,11 +17,21 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static CorsairDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="CorsairDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static CorsairDeviceProvider Instance => _instance ?? new CorsairDeviceProvider();
|
||||
public static CorsairDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new CorsairDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
@ -79,10 +89,13 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public CorsairDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -301,14 +314,20 @@ public sealed class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
try { _CUESDK.CorsairDisconnect(); } catch { /* at least we tried */ }
|
||||
try { _CUESDK.UnloadCUESDK(); } catch { /* at least we tried */ }
|
||||
try { _CUESDK.CorsairDisconnect(); }
|
||||
catch { /* at least we tried */ }
|
||||
|
||||
try { _CUESDK.UnloadCUESDK(); }
|
||||
catch { /* at least we tried */ }
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -16,11 +16,21 @@ public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static DMXDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="DMXDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static DMXDeviceProvider Instance => _instance ?? new DMXDeviceProvider();
|
||||
public static DMXDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new DMXDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all defined device-definitions.
|
||||
@ -36,10 +46,13 @@ public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public DMXDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(DMXDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -88,11 +101,14 @@ public sealed class DMXDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -16,11 +16,21 @@ public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static DebugDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="DebugDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static DebugDeviceProvider Instance => _instance ?? new DebugDeviceProvider();
|
||||
public static DebugDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new DebugDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
private List<(IDeviceLayout layout, Action<IEnumerable<Led>>? updateLedsAction)> _fakeDeviceDefinitions = new();
|
||||
|
||||
@ -33,10 +43,13 @@ public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public DebugDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(DebugDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -67,6 +80,8 @@ public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
@ -74,6 +89,7 @@ public sealed class DebugDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -20,11 +20,21 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static LogitechDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="LogitechDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static LogitechDeviceProvider Instance => _instance ?? new LogitechDeviceProvider();
|
||||
public static LogitechDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new LogitechDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
@ -164,9 +174,13 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public LogitechDeviceProvider()
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(LogitechDeviceProvider)}");
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null)
|
||||
throw new InvalidOperationException($"There can be only one instance of type {nameof(LogitechDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -255,6 +269,8 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
@ -266,6 +282,7 @@ public class LogitechDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -17,11 +17,21 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static MsiDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="MsiDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static MsiDeviceProvider Instance => _instance ?? new MsiDeviceProvider();
|
||||
public static MsiDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new MsiDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
@ -44,10 +54,13 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public MsiDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(MsiDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -99,6 +112,8 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
@ -107,6 +122,7 @@ public class MsiDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -17,11 +17,21 @@ public sealed class NovationDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static NovationDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="NovationDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static NovationDeviceProvider Instance => _instance ?? new NovationDeviceProvider();
|
||||
public static NovationDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new NovationDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -32,10 +42,13 @@ public sealed class NovationDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
private NovationDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(NovationDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -69,11 +82,14 @@ public sealed class NovationDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -14,6 +14,9 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private readonly List<OpenRgbClient> _clients = new();
|
||||
|
||||
private static OpenRGBDeviceProvider? _instance;
|
||||
@ -21,7 +24,14 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="OpenRGBDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static OpenRGBDeviceProvider Instance => _instance ?? new OpenRGBDeviceProvider();
|
||||
public static OpenRGBDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new OpenRGBDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all defined device-definitions.
|
||||
@ -47,10 +57,13 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public OpenRGBDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(OpenRGBDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -150,6 +163,8 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
@ -164,6 +179,7 @@ public sealed class OpenRGBDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -25,11 +25,21 @@ public sealed class PicoPiDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static PicoPiDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="PicoPiDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static PicoPiDeviceProvider Instance => _instance ?? new PicoPiDeviceProvider();
|
||||
public static PicoPiDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new PicoPiDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HID-definitions for PicoPi-devices.
|
||||
@ -56,10 +66,13 @@ public sealed class PicoPiDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public PicoPiDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(PicoPiDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -128,11 +141,14 @@ public sealed class PicoPiDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -19,11 +19,21 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static RazerDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="RazerDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static RazerDeviceProvider Instance => _instance ?? new RazerDeviceProvider();
|
||||
public static RazerDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new RazerDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
|
||||
@ -266,10 +276,13 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public RazerDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(RazerDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -343,6 +356,8 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
@ -354,6 +369,7 @@ public sealed class RazerDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -20,11 +20,21 @@ public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static SteelSeriesDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="SteelSeriesDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static SteelSeriesDeviceProvider Instance => _instance ?? new SteelSeriesDeviceProvider();
|
||||
public static SteelSeriesDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new SteelSeriesDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
private const int VENDOR_ID = 0x1038;
|
||||
|
||||
@ -92,10 +102,13 @@ public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public SteelSeriesDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(SteelSeriesDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -134,6 +147,8 @@ public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
@ -142,6 +157,7 @@ public sealed class SteelSeriesDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -16,11 +16,21 @@ public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static WS281XDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="WS281XDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static WS281XDeviceProvider Instance => _instance ?? new WS281XDeviceProvider();
|
||||
public static WS281XDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new WS281XDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all defined device-definitions.
|
||||
@ -38,10 +48,13 @@ public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public WS281XDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(WS281XDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -71,6 +84,8 @@ public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
@ -78,6 +93,7 @@ public sealed class WS281XDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -16,11 +16,21 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static readonly object _lock = new();
|
||||
|
||||
private static WootingDeviceProvider? _instance;
|
||||
/// <summary>
|
||||
/// Gets the singleton <see cref="WootingDeviceProvider"/> instance.
|
||||
/// </summary>
|
||||
public static WootingDeviceProvider Instance => _instance ?? new WootingDeviceProvider();
|
||||
public static WootingDeviceProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
return _instance ?? new WootingDeviceProvider();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 windows applications.
|
||||
@ -56,10 +66,13 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
|
||||
public WootingDeviceProvider()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance != null) throw new InvalidOperationException($"There can be only one instance of type {nameof(WootingDeviceProvider)}");
|
||||
_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -95,6 +108,8 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
@ -106,6 +121,7 @@ public sealed class WootingDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
_instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user