diff --git a/src/Workspaces/Remote/Core/SolutionAssetProvider.cs b/src/Workspaces/Remote/Core/SolutionAssetProvider.cs index ae3284f1fb18841f5168e15b69ef5fe89f3d925e..e42e34529a9d6a1352dc79b3e0b09aa663de31b6 100644 --- a/src/Workspaces/Remote/Core/SolutionAssetProvider.cs +++ b/src/Workspaces/Remote/Core/SolutionAssetProvider.cs @@ -59,7 +59,7 @@ public async ValueTask GetAssetsAsync(PipeWriter pipeWriter, int scopeId, Checks // (non-contiguous) memory allocated for the underlying buffers. The amount of memory is bounded by the total size of the serialized assets. var localPipe = new Pipe(RemoteHostAssetSerialization.PipeOptionsWithUnlimitedWriterBuffer); - Task.Run(() => + var task1 = Task.Run(() => { try { @@ -71,12 +71,14 @@ public async ValueTask GetAssetsAsync(PipeWriter pipeWriter, int scopeId, Checks { // no-op } - }, cancellationToken).Forget(); + }, cancellationToken); // Complete RPC once we send the initial piece of data and start waiting for the writer to send more, // so the client can start reading from the stream. Once CopyPipeDataAsync completes the pipeWriter // the corresponding client-side pipeReader will complete and the data transfer will be finished. - CopyPipeDataAsync().Forget(); + var task2 = CopyPipeDataAsync(); + + await Task.WhenAll(task1, task2).ConfigureAwait(false); async Task CopyPipeDataAsync() {