Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/UiPath.CoreIpc.Tests/Helpers/HttpSysWebSocketsListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,17 @@ public async Task<WebSocket> Accept(CancellationToken ct)
public async ValueTask DisposeAsync()
{
_cts.Cancel();
_httpListener.Stop();
_httpListener.Abort(); // Closes the request queue; unblocks pending GetContextAsync()
_httpListener.Close(); // Full resource cleanup

try
{
await _processingContexts;
// Safety net: on .NET Framework, GetContextAsync() may not respond to Abort()/Close().
await Task.WhenAny(_processingContexts, Task.Delay(TimeSpan.FromSeconds(5)));
}
catch (ObjectDisposedException)
catch
{
// ignore
}
catch (OperationCanceledException ex) when (ex.CancellationToken == _cts.Token)
{
// ignore
// Swallow ObjectDisposedException / OperationCanceledException from the listener shutdown.
}
}
}
Loading