Skip to content
Mark Lauter edited this page Jun 15, 2026 · 3 revisions

Pool

IPool<TPoolItem> is a thread-safe object pool for expensive-to-create, reusable instances — connections, clients, sockets. It hands items out under a lease, takes them back on release, and caps how many exist at once. That cap is a hard ceiling, so the pool doubles as a concurrency throttle.

Pool ships as the MSL.Pool NuGet package and targets .NET 10.

Where to go next

When to reach for Pool

Reach for Pool when an object is expensive to create and safe to reuse, and you want a hard ceiling on how many exist at once:

  • Connection pools — SMTP, database, or any long-lived network connection
  • Clients that hold a socket or session and cost real time to construct
  • Bounded concurrency — MaxSize caps concurrent leases, so the pool throttles load
  • Items that idle out — a connection the server drops after inactivity, re-checked on each lease

Skip Pool when the object is cheap to construct — allocate it directly. For stateless reset-and-reuse objects with no async readiness step, Microsoft.Extensions.ObjectPool is lighter. For HttpClient, use IHttpClientFactory.

Clone this wiki locally