Buffer
|
Note: This API is now obsolete.
[ObsoleteAttribute("It is not recommended to use this class because the need for pooling is rare and implementations of pooling can be dangerous.")] public static class BufferPool
The BufferPool type exposes the following members.
Name | Description | |
---|---|---|
Clear | Releases all the buffers currently cached in the pool. | |
ReturnBuffer | Returns a buffer to the pool. | |
TakeBuffer | Gets a buffer of at least the specified size from the pool. |
The buffer pool is statically created at application startup and is available for all components and classes within an application domain. Every time you need to use a buffer, you take one from the pool, use it, and return it to the pool when done.
It is very important to return the buffer to the pool when you are finished using it. If you are using a buffer scoped within a method, make sure to use a try/finally so that you can take the buffer within the try and return the buffer within the finally. If you are using a buffer as a member scoped class field, make sure you use the standard dispose pattern and return the buffer in the Dispose method.
Internally this class simply wraps a static instance of the WCF BufferManager.