1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 10:08:31 +00:00

Added native-unload to all deviceprovider-disposes

This commit is contained in:
Darth Affe 2020-03-03 14:30:12 +01:00
parent c98ffd2dbf
commit 1cfdeefde1
17 changed files with 60 additions and 29 deletions

View File

@ -267,7 +267,10 @@ namespace RGB.NET.Devices.Asus
/// <inheritdoc /> /// <inheritdoc />
public void Dispose() public void Dispose()
{ } {
try { _AsusSDK.UnloadAsusSDK(); }
catch { /* at least we tried */ }
}
#endregion #endregion
} }

View File

@ -75,7 +75,7 @@ namespace RGB.NET.Devices.Asus.Native
//_getDramColorPointer = (GetDramColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "GetDramColor"), typeof(GetDramColorPointer)); //_getDramColorPointer = (GetDramColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "GetDramColor"), typeof(GetDramColorPointer));
} }
private static void UnloadAsusSDK() internal static void UnloadAsusSDK()
{ {
if (_dllHandle == IntPtr.Zero) return; if (_dllHandle == IntPtr.Zero) return;

View File

@ -185,6 +185,9 @@ namespace RGB.NET.Devices.CoolerMaster
} }
catch {/* shit happens */} catch {/* shit happens */}
} }
try { _CoolerMasterSDK.UnloadCMSDK(); }
catch { /* at least we tried */ }
} }
#endregion #endregion

View File

@ -52,7 +52,7 @@ namespace RGB.NET.Devices.CoolerMaster.Native
_setAllLedColorPointer = (SetAllLedColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetAllLedColor"), typeof(SetAllLedColorPointer)); _setAllLedColorPointer = (SetAllLedColorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "SetAllLedColor"), typeof(SetAllLedColorPointer));
} }
private static void UnloadCMSDK() internal static void UnloadCMSDK()
{ {
if (_dllHandle == IntPtr.Zero) return; if (_dllHandle == IntPtr.Zero) return;

View File

@ -292,7 +292,10 @@ namespace RGB.NET.Devices.Corsair
/// <inheritdoc /> /// <inheritdoc />
public void Dispose() public void Dispose()
{ } {
try { _CUESDK.UnloadCUESDK(); }
catch { /* at least we tried */ }
}
#endregion #endregion
} }

View File

@ -56,7 +56,7 @@ namespace RGB.NET.Devices.Corsair.Native
_corsairGetLastErrorPointer = (CorsairGetLastErrorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLastError"), typeof(CorsairGetLastErrorPointer)); _corsairGetLastErrorPointer = (CorsairGetLastErrorPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "CorsairGetLastError"), typeof(CorsairGetLastErrorPointer));
} }
private static void UnloadCUESDK() internal static void UnloadCUESDK()
{ {
if (_dllHandle == IntPtr.Zero) return; if (_dllHandle == IntPtr.Zero) return;

View File

@ -182,7 +182,14 @@ namespace RGB.NET.Devices.Logitech
public void ResetDevices() => _LogitechGSDK.LogiLedRestoreLighting(); public void ResetDevices() => _LogitechGSDK.LogiLedRestoreLighting();
/// <inheritdoc /> /// <inheritdoc />
public void Dispose() => _LogitechGSDK.LogiLedRestoreLighting(); public void Dispose()
{
try { _LogitechGSDK.LogiLedRestoreLighting(); }
catch { /* at least we tried */ }
try { _LogitechGSDK.UnloadLogitechGSDK(); }
catch { /* at least we tried */ }
}
#endregion #endregion
} }

View File

@ -55,7 +55,7 @@ namespace RGB.NET.Devices.Logitech.Native
_logiLedSetLightingForTargetZonePointer = (LogiLedSetLightingForTargetZonePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "LogiLedSetLightingForTargetZone"), typeof(LogiLedSetLightingForTargetZonePointer)); _logiLedSetLightingForTargetZonePointer = (LogiLedSetLightingForTargetZonePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "LogiLedSetLightingForTargetZone"), typeof(LogiLedSetLightingForTargetZonePointer));
} }
private static void UnloadLogitechGSDK() internal static void UnloadLogitechGSDK()
{ {
if (_dllHandle == IntPtr.Zero) return; if (_dllHandle == IntPtr.Zero) return;

View File

@ -163,7 +163,10 @@ namespace RGB.NET.Devices.Msi
/// <inheritdoc /> /// <inheritdoc />
public void Dispose() public void Dispose()
{ } {
try { _MsiSDK.UnloadMsiSDK(); }
catch { /* at least we tried */ }
}
#endregion #endregion
} }

View File

@ -60,7 +60,7 @@ namespace RGB.NET.Devices.Msi.Native
_getErrorMessagePointer = (GetErrorMessagePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "MLAPI_GetErrorMessage"), typeof(GetErrorMessagePointer)); _getErrorMessagePointer = (GetErrorMessagePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "MLAPI_GetErrorMessage"), typeof(GetErrorMessagePointer));
} }
private static void UnloadMsiSDK() internal static void UnloadMsiSDK()
{ {
if (_dllHandle == IntPtr.Zero) return; if (_dllHandle == IntPtr.Zero) return;

View File

@ -52,7 +52,7 @@ namespace RGB.NET.Devices.Razer.Native
_deleteEffectPointer = (DeleteEffectPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "DeleteEffect"), typeof(DeleteEffectPointer)); _deleteEffectPointer = (DeleteEffectPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "DeleteEffect"), typeof(DeleteEffectPointer));
} }
private static void UnloadRazerSDK() internal static void UnloadRazerSDK()
{ {
if (_dllHandle == IntPtr.Zero) return; if (_dllHandle == IntPtr.Zero) return;

View File

@ -222,7 +222,13 @@ namespace RGB.NET.Devices.Razer
} }
/// <inheritdoc /> /// <inheritdoc />
public void Dispose() => TryUnInit(); public void Dispose()
{
TryUnInit();
try { _RazerSDK.UnloadRazerSDK(); }
catch { /* at least we tried */ }
}
#endregion #endregion
} }

View File

@ -27,11 +27,11 @@ namespace RGB.NET.Devices.Roccat.Native
/// </summary> /// </summary>
internal static void Reload() internal static void Reload()
{ {
UnloadCUESDK(); UnloadRoccatSDK();
LoadCUESDK(); LoadRoccatSDK();
} }
private static void LoadCUESDK() private static void LoadRoccatSDK()
{ {
if (_dllHandle != IntPtr.Zero) return; if (_dllHandle != IntPtr.Zero) return;
@ -57,7 +57,7 @@ namespace RGB.NET.Devices.Roccat.Native
_setAllLedSfxPointer = (SetAllLedSfxPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "Set_all_LEDSFX"), typeof(SetAllLedSfxPointer)); _setAllLedSfxPointer = (SetAllLedSfxPointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "Set_all_LEDSFX"), typeof(SetAllLedSfxPointer));
} }
private static void UnloadCUESDK() internal static void UnloadRoccatSDK()
{ {
if (_dllHandle == IntPtr.Zero) return; if (_dllHandle == IntPtr.Zero) return;

View File

@ -114,6 +114,9 @@ namespace RGB.NET.Devices.Roccat
try { _RoccatSDK.UnloadSDK(_sdkHandle); } try { _RoccatSDK.UnloadSDK(_sdkHandle); }
catch { /* We tried our best */} catch { /* We tried our best */}
} }
try { _RoccatSDK.UnloadRoccatSDK(); }
catch { /* at least we tried */ }
} }
#endregion #endregion

View File

@ -85,7 +85,9 @@ namespace RGB.NET.Devices.SteelSeries.API
internal static void Dispose() internal static void Dispose()
{ {
if (IsInitialized)
ResetLeds(); ResetLeds();
_client.Dispose(); _client.Dispose();
} }

View File

@ -52,7 +52,7 @@ namespace RGB.NET.Devices.Wooting.Native
_arraySetSinglePointer = (ArraySetSinglePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "wooting_rgb_array_set_single"), typeof(ArraySetSinglePointer)); _arraySetSinglePointer = (ArraySetSinglePointer)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_dllHandle, "wooting_rgb_array_set_single"), typeof(ArraySetSinglePointer));
} }
private static void UnloadWootingSDK() internal static void UnloadWootingSDK()
{ {
if (_dllHandle == IntPtr.Zero) return; if (_dllHandle == IntPtr.Zero) return;

View File

@ -144,9 +144,10 @@ namespace RGB.NET.Devices.Wooting
public void Dispose() public void Dispose()
{ {
try { _WootingSDK.Reset(); } try { _WootingSDK.Reset(); }
catch catch { /* Unlucky.. */ }
{ /* Unlucky.. */
} try { _WootingSDK.UnloadWootingSDK(); }
catch { /* at least we tried */ }
} }
#endregion #endregion