From fe41d940c98dd500fd8bf24a8f2695722e922740 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Mon, 22 Feb 2016 09:34:39 +0100 Subject: [PATCH] Corsair fix attempt --- .../KeyboardProviders/Corsair/CorsairRGB.cs | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs index 1fcc074a9..cdc207732 100644 --- a/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs +++ b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs @@ -1,4 +1,5 @@ using System.Drawing; +using System.Threading; using Artemis.Utilities; using CUE.NET; using CUE.NET.Brushes; @@ -22,23 +23,33 @@ namespace Artemis.KeyboardProviders.Corsair public override bool CanEnable() { - try + // Try for about 10 seconds + var tries = 0; + while (tries < 9) { - CueSDK.Initialize(); - } - catch (CUEException e) - { - if (e.Error == CorsairError.ServerNotFound) - return false; - throw; - } - catch (WrapperException) - { - CueSDK.Reinitialize(); + try + { + CueSDK.Initialize(); + } + catch (CUEException e) + { + if (e.Error == CorsairError.ServerNotFound) + { + tries++; + Thread.Sleep(1000); + continue; + } + } + catch (WrapperException) + { + CueSDK.Reinitialize(); + return true; + } + return true; } - return true; + return false; } ///