diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DisconnectHandler.cs b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DisconnectHandler.cs index 9fa9c3e65..4f2b8e85b 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DisconnectHandler.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DisconnectHandler.cs @@ -74,8 +74,8 @@ public async Task Handle(DisconnectArguments request, Cancel _logger.LogInformation("Debug adapter is shutting down..."); #pragma warning disable CS4014 - // Trigger the clean up of the debugger. No need to wait for it. - Task.Run(_psesDebugServer.OnSessionEnded, cancellationToken); + // Trigger the clean up of the debugger. No need to wait for it nor cancel it. + Task.Run(_psesDebugServer.OnSessionEnded, CancellationToken.None); #pragma warning restore CS4014 return new DisconnectResponse(); diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs index ff2db32a7..ec3923db0 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs @@ -765,7 +765,6 @@ public async Task> ExecuteCommandAsync( } // This is the primary reason that ExecuteCommandAsync takes a CancellationToken - cancellationToken.Register(() => shell.Stop()); return await Task.Run>( () => shell.Invoke(input: null, invocationSettings), cancellationToken) .ConfigureAwait(false); diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/Session/PSReadLinePromptContext.cs b/src/PowerShellEditorServices/Services/PowerShellContext/Session/PSReadLinePromptContext.cs index e74519913..62f5e21e2 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/Session/PSReadLinePromptContext.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/Session/PSReadLinePromptContext.cs @@ -144,7 +144,9 @@ public async Task InvokeReadLineAsync(bool isCommandLine, CancellationTo readLineCommand, errorMessages: null, s_psrlExecutionOptions, - cancellationToken).ConfigureAwait(false); + // NOTE: This command should always be allowed to complete, as the command itself + // has a linked cancellation token such that PSReadLine will be correctly cancelled. + CancellationToken.None).ConfigureAwait(false); string line = readLineResults.FirstOrDefault(); diff --git a/src/PowerShellEditorServices/Services/Symbols/Vistors/AstOperations.cs b/src/PowerShellEditorServices/Services/Symbols/Vistors/AstOperations.cs index e9972b12d..2251c56b3 100644 --- a/src/PowerShellEditorServices/Services/Symbols/Vistors/AstOperations.cs +++ b/src/PowerShellEditorServices/Services/Symbols/Vistors/AstOperations.cs @@ -62,7 +62,7 @@ public static async Task GetCompletionsAsync( ILogger logger, CancellationToken cancellationToken) { - if (!s_completionHandle.Wait(0, cancellationToken)) + if (!s_completionHandle.Wait(0, CancellationToken.None)) { return null; }