From 54439012b22c632d312b71ac1e31e76d679b7725 Mon Sep 17 00:00:00 2001 From: Colin Blaise Date: Tue, 1 Feb 2022 16:48:13 -0600 Subject: [PATCH 1/2] Added Thread.Sleep(100) to reduce CPU cycles --- .../Services/PowerShell/Host/PsesInternalHost.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs b/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs index a1ccee7b5..2d82202db 100644 --- a/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs +++ b/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs @@ -595,6 +595,7 @@ private void RunExecutionLoop() task.ExecuteSynchronously(cancellationScope.CancellationToken); } } + Thread.Sleep(100); } } From 6118fa7d74f05f980d97e3228cec497a82da4fde Mon Sep 17 00:00:00 2001 From: Colin Blaise Date: Fri, 4 Feb 2022 14:42:51 -0600 Subject: [PATCH 2/2] Throttle the REPL loop with a sleep because we're not interactively reading input from the user --- .../Services/PowerShell/Host/PsesInternalHost.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs b/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs index 2d82202db..b08c31ec5 100644 --- a/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs +++ b/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs @@ -595,7 +595,6 @@ private void RunExecutionLoop() task.ExecuteSynchronously(cancellationScope.CancellationToken); } } - Thread.Sleep(100); } } @@ -603,6 +602,8 @@ private void DoOneRepl(CancellationToken cancellationToken) { if (!_hostInfo.ConsoleReplEnabled) { + // Throttle the REPL loop with a sleep because we're not interactively reading input from the user. + Thread.Sleep(100); return; }