ADO.NET Provider for Email

Build 24.0.9060

Connection Pooling

The provider implements a standard ADO.NET connection pool. Set UseConnectionPooling to enable the pool. The following sections show how to configure and use them.

Working with Pooled Connections

Just as you would interact with a non-pooled connection, you use standard ADO.NET objects to get and close connections. But, in this case, the EmailConnection object retrieved is a handle for the physical connection owned by the connection pool. When the connection is closed, instead of the connection being destroyed, the handle is returned to the pool, where it is available for the next connection request.

You must explicitly close the connection for it to be returned to the pool.

Configuring the Connection Pool

In addition to UseConnectionPooling, set the following connection properties to control the connection pool:

  • PoolMaxSize: Define the maximum number of connections that can be open at any given time.
  • PoolIdleTimeout: Set a limit to how long connections can remain idle in the connection pool. If this limit is exceeded, the connection is removed from the pool.
  • PoolWaitTime: Set a limit to how long new connection requests should wait for a connection to become available. If this limit is exceeded, the request returns an error. By default, connection requests wait forever for a connection to become available.

Connection Pooling with EmailConnection

To use the default method for pooling connections, instantiate the EmailConnection with UseConnectionPooling:

C#

using (EmailConnection connection = new EmailConnection("UseConnectionPooling=true;Port=993;Server=outlook.office365.com;Password=password;User=user;Protocol=IMAP;SMTP Port=587;SMTP Server=smtp.office365.com;")) {connection.Open();}

VB.NET

Using (EmailConnection connection = new EmailConnection("UseConnectionPooling=true;Port=993;Server=outlook.office365.com;Password=password;User=user;Protocol=IMAP;SMTP Port=587;SMTP Server=smtp.office365.com;")) 
  connection.Open()
End Using

Closing the Connection Pool

The connection pool is closed when the active process ends.

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060