Skip to content

Commit

Permalink
missing dispose in NamedPipeClient (#3833)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Sep 15, 2024
1 parent ebf14d7 commit 0f49ad7
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/Platform/Microsoft.Testing.Platform/IPC/NamedPipeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,21 +202,31 @@ public async Task<TResponse> RequestReplyAsync<TRequest, TResponse>(TRequest req

public void Dispose()
{
if (!_disposed)
if (_disposed)
{
_namedPipeClientStream.Dispose();
_disposed = true;
return;
}

_lock.Dispose();
_serializationBuffer.Dispose();
_messageBuffer.Dispose();
_namedPipeClientStream.Dispose();
_disposed = true;
}

#if NETCOREAPP
public async ValueTask DisposeAsync()
{
if (!_disposed)
if (_disposed)
{
await _namedPipeClientStream.DisposeAsync();
_disposed = true;
return;
}

_lock.Dispose();
await _serializationBuffer.DisposeAsync();
await _messageBuffer.DisposeAsync();
await _namedPipeClientStream.DisposeAsync();
_disposed = true;
}
#endif
}

0 comments on commit 0f49ad7

Please sign in to comment.