From 92c7b50d6d26140fa0904df0f9f23435ad63d9f2 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 5 Mar 2018 15:53:40 -0600 Subject: [PATCH] Re-add delay on device disable --- DS4Windows/DS4Library/DS4Devices.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DS4Windows/DS4Library/DS4Devices.cs b/DS4Windows/DS4Library/DS4Devices.cs index 06a0b12..cc7b92b 100644 --- a/DS4Windows/DS4Library/DS4Devices.cs +++ b/DS4Windows/DS4Library/DS4Devices.cs @@ -309,6 +309,16 @@ namespace DS4Windows } */ + //System.Threading.Thread.Sleep(50); + sw.Restart(); + while (sw.ElapsedMilliseconds < 50) + { + // Use SpinWait to keep control of current thread. Using Sleep could potentially + // cause other events to get run out of order + System.Threading.Thread.SpinWait(100); + } + sw.Stop(); + propChangeParams.stateChange = NativeMethods.DICS_ENABLE; success = NativeMethods.SetupDiSetClassInstallParams(deviceInfoSet, ref deviceInfoData, ref propChangeParams, Marshal.SizeOf(propChangeParams)); if (!success)