on msdn there is an article about object pool,using wcf extention,we can do more,but there is too much service in my project ,i donn't want to write repeatedly,does wcf have built-in support for object pool

I need such object pool, can config min and max object pool can share object when client require more then max object pool

3.after fastigium on 9:00am and 4:00pm,object can reduse,and release resource

Re: Windows Communication Foundation (Indigo) about object pool on wcf

Dave Cliffe - MSFT

Hi Alphais,

No, WCF does not have this support built in. But you can very easily share this behavior across multiple services and add it to the respective services via config. Here is the sample that I think you are referring to: url=/library/en-us/WCF_Samples_MSDNLive/html/688dfb30-b79a-4cad-a687-8302f8a9ad6a.asp

In that sample, it shows a snippet of code to apply it to any number of dispatchers as follows:

Code Snippet
void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase)
// Create an instance of the ObjectPoolInstanceProvider.
ObjectPoolingInstanceProvider instanceProvider = new ObjectPoolingInstanceProvider(description.ServiceType,
maxPoolSize, minPoolSize, creationTimeout);

foreach (ChannelDispatcherBase cdb in serviceHostBase.ChannelDispatchers)
ChannelDispatcher cd = cdb as ChannelDispatcher;
if (cd != null)
foreach (EndpointDispatcher ed in cd.Endpoints)
// Assign it to DispatchBehavior in each endpoint.
ed.DispatchRuntime.InstanceProvider = instanceProvider;

You can build your custom behavior to satisfy the requirements you mentioned.

-- Dave

Re: Windows Communication Foundation (Indigo) about object pool on wcf

Oren Fisher - MSFT


The functionality you mentioned is not an out-of-box feature of WCF; however as part of the extensibility samples, there is a specific sample for pooling (see url=/library/en-us/WCF_Samples_MSDNLive/html/688dfb30-b79a-4cad-a687-8302f8a9ad6a.asp). That implementation, enables you to implement the pooling once, then apply it whenever you need it as a simple attribute to the class implementing the service contract.

I suppose that you can extend the functionality in this pooling extension to the specific characteristics of your desire pool.

Oren Fisher,

Microsoft, Connected Frameworks