protected override void OnSingleItemRemoved(ChannelFactoryRef <TChannel> item) { if (item.Release()) { item.Abort(); } }
protected override void OnSingleItemRemoved(ChannelFactoryRef <TChannel> item) { // Remove from cache. if (item.Release()) { item.Abort(); } if (TD.ClientBaseCachedChannelFactoryCountIsEnabled()) { TD.ClientBaseCachedChannelFactoryCount(this.Count, this.watermark, this); } }
protected override void OnSingleItemRemoved(ChannelFactoryRef <TChannel> item) { // Remove from cache. if (item.Release()) { item.Abort(); } if (WcfEventSource.Instance.ClientBaseCachedChannelFactoryCountIsEnabled()) { WcfEventSource.Instance.ClientBaseCachedChannelFactoryCount(Count, _watermark, this); } }
// Once the channel is created, we can't disable caching. // This method can be called safely multiple times. // this.sharingFinalized is set the first time the method is called. // Subsequent calls are essentially no-ops. void TryDisableSharing() { if (_sharingFinalized) { return; } lock (finalizeLock) { if (_sharingFinalized) { return; } _canShareFactory = false; _sharingFinalized = true; if (_useCachedFactory) { ChannelFactoryRef <TChannel> pendingFactoryRef = _channelFactoryRef; _channelFactoryRef = CreateChannelFactoryRef(_endpointTrait); _useCachedFactory = false; lock (s_staticLock) { if (!pendingFactoryRef.Release()) { pendingFactoryRef = null; } } if (pendingFactoryRef != null) { pendingFactoryRef.Abort(); } } } // can be done outside the lock since the lines below do not access shared data. // also the use of this.sharingFinalized in the lines above ensures that tracing // happens only once and only when needed. if (WcfEventSource.Instance.ClientBaseUsingLocalChannelFactoryIsEnabled()) { WcfEventSource.Instance.ClientBaseUsingLocalChannelFactory(this); } }