@@ -2318,10 +2318,10 @@ public async Task LongPollingConnectionClosingTriggersConnectionClosedToken()
2318
2318
Assert . Equal ( "text/plain" , deleteContext . Response . ContentType ) ;
2319
2319
Assert . Equal ( HttpConnectionStatus . Disposed , connection . Status ) ;
2320
2320
2321
+ await connection . ConnectionClosed . WaitForCancellationAsync ( ) . OrTimeout ( ) ;
2322
+
2321
2323
// Verify the connection not removed because application is hanging
2322
2324
Assert . True ( manager . TryGetConnection ( connection . ConnectionId , out _ ) ) ;
2323
-
2324
- Assert . True ( connection . ConnectionClosed . IsCancellationRequested ) ;
2325
2325
}
2326
2326
}
2327
2327
@@ -2348,9 +2348,7 @@ public async Task SSEConnectionClosingTriggersConnectionClosedToken()
2348
2348
// Close the SSE connection
2349
2349
connection . Transport . Output . Complete ( ) ;
2350
2350
2351
- var tcs = new TaskCompletionSource < object > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
2352
- connection . ConnectionClosed . Register ( ( ) => tcs . SetResult ( null ) ) ;
2353
- await tcs . Task . OrTimeout ( ) ;
2351
+ await connection . ConnectionClosed . WaitForCancellationAsync ( ) . OrTimeout ( ) ;
2354
2352
}
2355
2353
}
2356
2354
@@ -2381,9 +2379,7 @@ public async Task WebSocketConnectionClosingTriggersConnectionClosedToken()
2381
2379
await websocket . Accepted . OrTimeout ( ) ;
2382
2380
await websocket . Client . CloseOutputAsync ( WebSocketCloseStatus . NormalClosure , "" , cancellationToken : default ) . OrTimeout ( ) ;
2383
2381
2384
- var tcs = new TaskCompletionSource < object > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
2385
- connection . ConnectionClosed . Register ( ( ) => tcs . SetResult ( null ) ) ;
2386
- await tcs . Task . OrTimeout ( ) ;
2382
+ await connection . ConnectionClosed . WaitForCancellationAsync ( ) . OrTimeout ( ) ;
2387
2383
}
2388
2384
}
2389
2385
0 commit comments