<PackageReference Include="Microsoft.Data.SqlClient" Version="7.1.0-preview3.26238.4" />

Microsoft.Data.SqlClient.ConnectionPool.PoolReclaimer

sealed class PoolReclaimer : IDisposable
Drives background sweeps for emancipated connections in ChannelDbConnectionPool while callers are parked waiting for a connection.

A connection becomes emancipated when its owning DbConnection is garbage collected without ever being closed or disposed. Emancipation only becomes observable once the collector has run, which routinely happens after a caller has already parked, so a single sweep at request time cannot cover it. Without a background sweep every parked caller would wait out its full timeout even though a pool slot was recoverable the whole time.

The sweep cannot run on the parked caller's own thread. ChannelDbConnectionPool relies on the FIFO ordering that Channel guarantees to readers, so a parked caller that cancelled its read in order to re-sweep would lose its place in line to callers that arrived later. The sweep therefore runs on a timer callback instead.

The timer is demand-driven: it is armed when the first caller parks and disarmed when the last one leaves, so a pool with no blocked callers never wakes the process. This mirrors the approach taken for the connection factory's pruning timer (issue #1881).

public void Dispose()

Stops the sweep timer and releases resources. Safe to call multiple times.