private void initialiseSdk(bool exclusiveLightingControl) { ProtocolDetails = CorsairLightingSDK.PerformProtocolHandshake(); if (ProtocolDetails.ServerProtocolVersion == 0) { if (!HandleError()) { //server not found... seep 10 seconds and try again Thread.Sleep(10000); initialiseSdk(exclusiveLightingControl); return; } } if (ProtocolDetails.BreakingChanges) { String sdkVersion = ProtocolDetails.SdkVersion; String cueVersion = ProtocolDetails.ServerVersion; throw new Exception("Incompatible SDK (" + sdkVersion + ") and CUE " + cueVersion + " versions."); } if (exclusiveLightingControl) { CorsairLightingSDK.RequestControl(CorsairAccessMode.ExclusiveLightingControl); HasExclusiveLightingControl = true; } }
/// <summary> /// Performs a health check on the provider /// </summary> public void PerformHealthCheck() { var cueRunning = Process.GetProcessesByName("iCUE").Length != 0; while (!cueRunning) { Thread.Sleep(1000); cueRunning = Process.GetProcessesByName("iCUE").Length != 0; } CorsairLightingSDK.GetDeviceCount(); var error = CorsairLightingSDK.GetLastError(); while (error == CorsairError.ServerNotFound || error == CorsairError.ProtocolHandshakeMissing) { CorsairLightingSDK.PerformProtocolHandshake(); Thread.Sleep(1000); error = CorsairLightingSDK.GetLastError(); } }