Skip to content

Commit

Permalink
handle object disposed exception (#4221)
Browse files Browse the repository at this point in the history
Co-authored-by: Marco Rossignoli <mrossignol@microsoft.com>
  • Loading branch information
MarcoRossignoli and Marco Rossignoli committed Dec 22, 2022
1 parent 236a428 commit 16c004d
Showing 1 changed file with 11 additions and 3 deletions.
Expand Up @@ -111,9 +111,17 @@ public Task NotifyDataAvailable()
/// <inheritdoc />
public void Dispose()
{
EqtTrace.Verbose("LengthPrefixCommunicationChannel.Dispose: Dispose reader and writer.");
_reader.Dispose();
_writer.Dispose();
try
{
EqtTrace.Verbose("LengthPrefixCommunicationChannel.Dispose: Dispose reader and writer.");
_reader.Dispose();
_writer.Dispose();
}
catch (ObjectDisposedException)
{
// We don't own the underlying stream lifecycle so it's possible that it's already disposed.
}

GC.SuppressFinalize(this);
}
}

0 comments on commit 16c004d

Please sign in to comment.