Skip to content

Commit

Permalink
Wait for GetAssetsAsync before returning
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Sep 30, 2020
1 parent ebb674f commit c020fe8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Workspaces/Remote/Core/SolutionAssetProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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()
{
Expand Down

0 comments on commit c020fe8

Please sign in to comment.