Skip to content

Commit

Permalink
Merge pull request #14967 from heejaechang/objectdisposed2
Browse files Browse the repository at this point in the history
add object dispose check to one missing place.
  • Loading branch information
heejaechang authored Nov 4, 2016
2 parents 9c3148e + 8c234c9 commit 5bfc051
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/VisualStudio/Core/Next/Remote/JsonRpcSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,23 @@ private JsonRpcSession(

private async Task InitializeAsync()
{
// all roslyn remote service must based on ServiceHubServiceBase which implements Initialize method
await _snapshotClient.InvokeAsync(WellKnownServiceHubServices.ServiceHubServiceBase_Initialize, _currentSessionId, PinnedScope.SolutionChecksum.ToArray()).ConfigureAwait(false);
await _serviceClient.InvokeAsync(WellKnownServiceHubServices.ServiceHubServiceBase_Initialize, _currentSessionId, PinnedScope.SolutionChecksum.ToArray()).ConfigureAwait(false);
CancellationToken.ThrowIfCancellationRequested();

try
{
// all roslyn remote service must based on ServiceHubServiceBase which implements Initialize method
await _snapshotClient.InvokeAsync(WellKnownServiceHubServices.ServiceHubServiceBase_Initialize, _currentSessionId, PinnedScope.SolutionChecksum.ToArray()).ConfigureAwait(false);
await _serviceClient.InvokeAsync(WellKnownServiceHubServices.ServiceHubServiceBase_Initialize, _currentSessionId, PinnedScope.SolutionChecksum.ToArray()).ConfigureAwait(false);
}
catch (ObjectDisposedException)
{
// object disposed exception can be thrown from StreamJsonRpc if JsonRpc is disposed in the middle of read/write.
// the way we added cancellation support to the JsonRpc which doesn't support cancellation natively
// can cause this exception to happen. newer version supports cancellation token natively, but
// we can't use it now, so we will catch object disposed exception and check cancellation token
CancellationToken.ThrowIfCancellationRequested();
throw;
}
}

public override async Task InvokeAsync(string targetName, params object[] arguments)
Expand Down

0 comments on commit 5bfc051

Please sign in to comment.