Closing Channel after invocation


All samples show the normal WCF stuff for channel creation:
    #region Channel Helpers
    static IService GetChannel()
        ChannelFactory<IService> factory = new ChannelFactory<IService>("ServiceEP");
        return factory.CreateChannel();
    static void CloseChannel(IService channel)
Is there a plan to put an interceptor that would close the channel on a successful invocation, or abort it on a fault so that doesn't have to be manual process?


zuker wrote Apr 13, 2010 at 10:18 AM

Sorry for late response.

WCF Contrib provides you with client infrastructure that manages the proxy creation and life-time for you.
This means that WCF Contrib provides you with what you mentioned.

When constructing a Client Channel (of WCF Contrib), you can select the channel management options that will affect the proxy creation and life-time management within the infrastructure.
If, for example, you construct it with "SingleCall" - Each invocation will create a dedicated communication proxy and appropriately dispose of that when done. In this case, you don't have to care about the initialization and the disposing of the communication channels.

Do note, that when you use different management options where the underlying communication channel isn't terminated, such as Sequential (the communication channel is preserved throughout the calls unless it goes faulted which then the infrastructure renews it), you should dispose of the client channel and that will terminate whatever was created.
In such modes, there isn't really a way for WCF Contrib to determine when it should terminate the communication proxy unless you explicitly dispose of the client channel.

wrote Feb 14, 2013 at 12:02 AM