From 78c689eb08f849f1a9750428a2590130abb81f5e Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Wed, 9 Aug 2023 18:02:32 +0200 Subject: [PATCH] Increased GPU restart delay --- app/Display/ScreenNative.cs | 9 --------- app/Gpu/NVidia/NvidiaGpuControl.cs | 5 +++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app/Display/ScreenNative.cs b/app/Display/ScreenNative.cs index 99fd2b2f..4379796d 100644 --- a/app/Display/ScreenNative.cs +++ b/app/Display/ScreenNative.cs @@ -234,15 +234,6 @@ namespace GHelper.Display dm.dmDisplayFrequency = frequency; int iRet = ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero); Logger.WriteLine("Screen = " + frequency.ToString() + "Hz : " + (iRet == 0 ? "OK" : iRet)); - - //Fallback scenario - if (iRet != 0) - { - Thread.Sleep(500); - iRet = ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero); - Logger.WriteLine("Screen = " + frequency.ToString() + "Hz : " + (iRet == 0 ? "OK" : iRet)); - } - return iRet; } diff --git a/app/Gpu/NVidia/NvidiaGpuControl.cs b/app/Gpu/NVidia/NvidiaGpuControl.cs index a3bee55b..22152b29 100644 --- a/app/Gpu/NVidia/NvidiaGpuControl.cs +++ b/app/Gpu/NVidia/NvidiaGpuControl.cs @@ -72,7 +72,7 @@ public class NvidiaGpuControl : IGpuControl Logger.WriteLine(ex.Message); } - //NVIDIA.RestartDisplayDriver(); + //GeneralApi.RestartDisplayDriver(); } @@ -112,7 +112,8 @@ public class NvidiaGpuControl : IGpuControl { try { - string script = @"$device = Get-PnpDevice | Where-Object { $_.FriendlyName -imatch 'NVIDIA' -and $_.Class -eq 'Display' }; Disable-PnpDevice $device.InstanceId -Confirm:$false; Start-Sleep -Seconds 3; Enable-PnpDevice $device.InstanceId -Confirm:$false"; + + string script = @"$device = Get-PnpDevice | Where-Object { $_.FriendlyName -imatch 'NVIDIA' -and $_.Class -eq 'Display' }; Disable-PnpDevice $device.InstanceId -Confirm:$false; Start-Sleep -Seconds 5; Enable-PnpDevice $device.InstanceId -Confirm:$false"; Logger.WriteLine(script); ProcessHelper.RunCMD("powershell", script); //Thread.Sleep(2000);