NamedPipeClientPool
Namespace: TagBites.Pipes
Assembly: TagBites.Pipes.dll
Product: TagBites.Pipes v. 1.2.0
Keeps a bounded set of reusable connections to a NamedPipeServer and hands them out to callers, so several threads can send requests at once.
public class NamedPipeClientPool : System.IDisposableInheritance: object → NamedPipeClientPool
Remarks
Section titled “Remarks”The pool does not guarantee a live connection. A connection that the server dropped while it sat idle fails the next request with NamedPipeConnectionLostException; the pool then discards it, so the request after that gets a fresh one. Callers have to handle that exception. A caller blocks while every connection is busy.
Constructors
Section titled “Constructors”NamedPipeClientPool(string, int)
Section titled “NamedPipeClientPool(string, int)”Initializes a new instance of the NamedPipeClientPool class.
public NamedPipeClientPool(string pipeName, int maxConnections)Parameters
Section titled “Parameters”pipeNamestring
The name of the pipe to connect to.maxConnectionsint
The largest number of connections held at once.
Exceptions
Section titled “Exceptions”- ArgumentNullException -
pipeNameisnull. - ArgumentOutOfRangeException -
maxConnectionsis less than one.
Properties
Section titled “Properties”IsDisposed
Section titled “IsDisposed”Gets a value indicating whether the pool has been disposed.
public bool IsDisposed { get; }Property Value
Section titled “Property Value”PipeName
Section titled “PipeName”Gets the name of the pipe the connections point to.
public string PipeName { get; }Property Value
Section titled “Property Value”Methods
Section titled “Methods”Dispose()
Section titled “Dispose()”Waits for every request in flight to finish, then closes all connections.
public virtual void Dispose()GetConnection()
Section titled “GetConnection()”Takes a connection for several requests in a row. Disposing the returned link gives the connection back to the pool.
public NamedPipeClientPoolLink GetConnection()Returns
Section titled “Returns”A link holding one connection from the pool.
Exceptions
Section titled “Exceptions”- ObjectDisposedException - The pool has been disposed.
GetConnectionAsync()
Section titled “GetConnectionAsync()”Takes a connection for several requests in a row. Disposing the returned link gives the connection back to the pool.
public Task<NamedPipeClientPoolLink> GetConnectionAsync()Returns
Section titled “Returns”A link holding one connection from the pool.
Exceptions
Section titled “Exceptions”- ObjectDisposedException - The pool has been disposed.
SendRequest(string, string)
Section titled “SendRequest(string, string)”Takes a connection, sends a request on it and returns it to the pool.
public string SendRequest(string address, string message)Parameters
Section titled “Parameters”addressstring
The address naming the operation. It must not start with--.messagestring
The message to send.
Returns
Section titled “Returns”The response text, which is empty when the handler set no response.
Exceptions
Section titled “Exceptions”- ObjectDisposedException - The pool has been disposed.
- NamedPipeConnectionLostException - The connection broke while sending or receiving.
- NamedPipeServerRemoteException - The request handler on the server failed.
SendRequestAsync(string, string)
Section titled “SendRequestAsync(string, string)”Takes a connection, sends a request on it and returns it to the pool.
public Task<string> SendRequestAsync(string address, string message)Parameters
Section titled “Parameters”addressstring
The address naming the operation. It must not start with--.messagestring
The message to send.
Returns
Section titled “Returns”The response text, which is empty when the handler set no response.
Exceptions
Section titled “Exceptions”- ObjectDisposedException - The pool has been disposed.
- NamedPipeConnectionLostException - The connection broke while sending or receiving.
- NamedPipeServerRemoteException - The request handler on the server failed.