Add wait period after device is enabled.

Seems to be needed for exclusive mode to behave better
with recent Windows 10 update
This commit is contained in:
Travis Nickles 2017-08-01 02:42:16 -05:00
parent 4af6404b49
commit f042120ede

View File

@ -284,6 +284,7 @@ namespace DS4Windows
throw new Exception("Error disabling device, error code = " + Marshal.GetLastWin32Error());
}
//System.Threading.Thread.Sleep(50);
sw.Start();
while (sw.ElapsedMilliseconds < 50)
{
@ -305,6 +306,15 @@ namespace DS4Windows
throw new Exception("Error enabling device, error code = " + Marshal.GetLastWin32Error());
}
//System.Threading.Thread.Sleep(10);
sw.Restart();
while (sw.ElapsedMilliseconds < 10)
{
// 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(20);
}
sw.Stop();
NativeMethods.SetupDiDestroyDeviceInfoList(deviceInfoSet);
}
}