Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / TransportReplyChannelAcceptor.cs / 1 / TransportReplyChannelAcceptor.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Channels { using System.Collections.Generic; using System.Diagnostics; using System.ServiceModel.Diagnostics; class TransportReplyChannelAcceptor : ReplyChannelAcceptor { TransportManagerContainer transportManagerContainer; TransportChannelListener listener; public TransportReplyChannelAcceptor(TransportChannelListener listener) : base(listener) { this.listener = listener; } protected override ReplyChannel OnCreateChannel() { return new TransportReplyChannel(this.ChannelManager, null); } protected override void OnOpening() { base.OnOpening(); this.transportManagerContainer = this.listener.GetTransportManagers(); this.listener = null; } protected override void OnAbort() { base.OnAbort(); if (this.transportManagerContainer != null && !TransferTransportManagers()) { this.transportManagerContainer.Close(); } } IAsyncResult DummyBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { return new CompletedAsyncResult(callback, state); } void DummyEndClose(IAsyncResult result) { CompletedAsyncResult.End(result); } protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { ChainedBeginHandler begin1 = DummyBeginClose; ChainedEndHandler end1 = DummyEndClose; if (this.transportManagerContainer != null && !TransferTransportManagers()) { begin1 = this.transportManagerContainer.BeginClose; end1 = this.transportManagerContainer.EndClose; } return new ChainedAsyncResult(timeout, callback, state, base.OnBeginClose, base.OnEndClose, begin1, end1); } protected override void OnEndClose(IAsyncResult result) { ChainedAsyncResult.End(result); } protected override void OnClose(TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); base.OnClose(timeoutHelper.RemainingTime()); if (this.transportManagerContainer != null && !TransferTransportManagers()) { this.transportManagerContainer.Close(); } } // used to decouple our channel and listener lifetimes bool TransferTransportManagers() { TransportReplyChannel singletonChannel = (TransportReplyChannel)base.GetCurrentChannel(); if (singletonChannel == null) { return false; } else { return singletonChannel.TransferTransportManagers(this.transportManagerContainer); } } // tracks TransportManager so that the channel can outlive the Listener protected class TransportReplyChannel : ReplyChannel { TransportManagerContainer transportManagerContainer; public TransportReplyChannel(ChannelManagerBase channelManager, EndpointAddress localAddress) : base(channelManager, localAddress) { } public bool TransferTransportManagers(TransportManagerContainer transportManagerContainer) { lock (ThisLock) { if (this.State != CommunicationState.Opened) { return false; } this.transportManagerContainer = transportManagerContainer; return true; } } protected override void OnAbort() { if (this.transportManagerContainer != null) { this.transportManagerContainer.Close(); } base.OnAbort(); } protected override void OnClose(TimeSpan timeout) { if (this.transportManagerContainer != null) { this.transportManagerContainer.Close(); } base.OnClose(timeout); } IAsyncResult DummyBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { return new CompletedAsyncResult(callback, state); } void DummyEndClose(IAsyncResult result) { CompletedAsyncResult.End(result); } protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { ChainedBeginHandler begin1 = DummyBeginClose; ChainedEndHandler end1 = DummyEndClose; if (this.transportManagerContainer != null) { begin1 = this.transportManagerContainer.BeginClose; end1 = this.transportManagerContainer.EndClose; } return new ChainedAsyncResult(timeout, callback, state, begin1, end1, base.OnBeginClose, base.OnEndClose); } protected override void OnEndClose(IAsyncResult result) { ChainedAsyncResult.End(result); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ZipIOCentralDirectoryFileHeader.cs
- PathSegmentCollection.cs
- ObjectContextServiceProvider.cs
- HtmlElement.cs
- XmlDataSource.cs
- Int32KeyFrameCollection.cs
- TypeReference.cs
- EventSetterHandlerConverter.cs
- ProvidePropertyAttribute.cs
- TouchEventArgs.cs
- StopStoryboard.cs
- ChtmlSelectionListAdapter.cs
- Geometry.cs
- CodeChecksumPragma.cs
- MultiByteCodec.cs
- ToolStripHighContrastRenderer.cs
- RegexGroup.cs
- Socket.cs
- DateTimeValueSerializerContext.cs
- DependencySource.cs
- TextTreePropertyUndoUnit.cs
- LazyTextWriterCreator.cs
- HttpServerUtilityWrapper.cs
- ResourceCategoryAttribute.cs
- PackageDigitalSignatureManager.cs
- EditorBrowsableAttribute.cs
- LabelDesigner.cs
- SystemResourceKey.cs
- CorePropertiesFilter.cs
- PasswordTextContainer.cs
- MessageSecurityOverTcp.cs
- ServiceConfigurationTraceRecord.cs
- AdRotator.cs
- WindowsGrip.cs
- ModelTreeEnumerator.cs
- LineUtil.cs
- DomainUpDown.cs
- XamlClipboardData.cs
- InkPresenterAutomationPeer.cs
- GatewayIPAddressInformationCollection.cs
- DataServiceBehavior.cs
- Visual3D.cs
- Point3D.cs
- PluralizationService.cs
- ToolboxItemCollection.cs
- RecordConverter.cs
- RequestDescription.cs
- DiscoveryClientDocuments.cs
- Misc.cs
- UserUseLicenseDictionaryLoader.cs
- _CacheStreams.cs
- RandomNumberGenerator.cs
- StringValidatorAttribute.cs
- ListItemConverter.cs
- UnsafeNativeMethods.cs
- DirectionalLight.cs
- DiscoveryMessageSequenceGenerator.cs
- OleDbConnection.cs
- RangeExpression.cs
- PropertyGridDesigner.cs
- ArrayWithOffset.cs
- XmlRootAttribute.cs
- HttpHandler.cs
- DataKeyCollection.cs
- COAUTHIDENTITY.cs
- SingleAnimationUsingKeyFrames.cs
- FlowLayoutPanelDesigner.cs
- ClientScriptManager.cs
- FormViewRow.cs
- ProviderUtil.cs
- printdlgexmarshaler.cs
- unitconverter.cs
- Constants.cs
- X509SecurityTokenProvider.cs
- PKCS1MaskGenerationMethod.cs
- MsmqInputChannel.cs
- BulletDecorator.cs
- EventlogProvider.cs
- PrinterResolution.cs
- WindowsStreamSecurityUpgradeProvider.cs
- PermissionSetEnumerator.cs
- FlowDocumentReaderAutomationPeer.cs
- ObjectCache.cs
- StringAnimationBase.cs
- SqlDependencyListener.cs
- NativeMethods.cs
- BooleanExpr.cs
- ListViewDataItem.cs
- WebResourceAttribute.cs
- SspiSafeHandles.cs
- dtdvalidator.cs
- ClientSponsor.cs
- PolicyChain.cs
- EncoderParameter.cs
- BuildManager.cs
- PageCatalogPartDesigner.cs
- StylusPoint.cs
- DriveNotFoundException.cs
- RuntimeConfigurationRecord.cs
- IdentityValidationException.cs