diff --git a/src/RazorSdk/Tool/Client.cs b/src/RazorSdk/Tool/Client.cs index 01175a94ac12..9661ec1dcef2 100644 --- a/src/RazorSdk/Tool/Client.cs +++ b/src/RazorSdk/Tool/Client.cs @@ -171,9 +171,9 @@ public override async Task WaitForDisconnectAsync(CancellationToken cancellation try { ServerLogger.Log($"Before poking pipe {Identifier}."); -#pragma warning disable CA2022 // Avoid inexact read - await Stream.ReadAsync(Array.Empty(), 0, 0, cancellationToken); -#pragma warning restore CA2022 + // Stream.ReadExactlyAsync with a zero-length buffer will not update the state of the pipe. + // We need to trigger a state update without actually reading the data. + _ = await Stream.ReadAsync(Array.Empty(), 0, 0, cancellationToken); ServerLogger.Log($"After poking pipe {Identifier}."); } catch (OperationCanceledException) diff --git a/src/RazorSdk/Tool/ConnectionHost.cs b/src/RazorSdk/Tool/ConnectionHost.cs index f92397d6e994..018848492b4c 100644 --- a/src/RazorSdk/Tool/ConnectionHost.cs +++ b/src/RazorSdk/Tool/ConnectionHost.cs @@ -107,9 +107,9 @@ public override async Task WaitForDisconnectAsync(CancellationToken cancellation try { ServerLogger.Log($"Before poking pipe {Identifier}."); -#pragma warning disable CA2022 // Avoid inexact read - await Stream.ReadAsync(Array.Empty(), 0, 0, cancellationToken); -#pragma warning restore CA2022 + // Stream.ReadExactlyAsync with a zero-length buffer will not update the state of the pipe. + // We need to trigger a state update without actually reading the data. + _ = await Stream.ReadAsync(Array.Empty(), 0, 0, cancellationToken); ServerLogger.Log($"After poking pipe {Identifier}."); } catch (OperationCanceledException)