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
- CalculatedColumn.cs
- ContextDataSource.cs
- CapabilitiesSection.cs
- IdentifierService.cs
- LoginName.cs
- CommandID.cs
- NamedPipeConnectionPool.cs
- XmlQueryTypeFactory.cs
- XPathNodePointer.cs
- SplashScreenNativeMethods.cs
- ImageListDesigner.cs
- ReliableRequestSessionChannel.cs
- WindowsFont.cs
- FtpRequestCacheValidator.cs
- NullableBoolConverter.cs
- Nullable.cs
- PieceDirectory.cs
- TcpTransportElement.cs
- SqlClientFactory.cs
- MetadataSource.cs
- XhtmlBasicCalendarAdapter.cs
- MetafileHeader.cs
- BitArray.cs
- PointHitTestResult.cs
- AutomationElement.cs
- Type.cs
- SvcMapFile.cs
- WindowsListBox.cs
- OutputCacheModule.cs
- AdCreatedEventArgs.cs
- Evidence.cs
- Package.cs
- XPathDocumentIterator.cs
- LinkTarget.cs
- StreamHelper.cs
- MetabaseSettings.cs
- EditCommandColumn.cs
- RegexRunner.cs
- LocalizableAttribute.cs
- ImageBrush.cs
- NullReferenceException.cs
- XsdBuildProvider.cs
- StringSource.cs
- MethodExpr.cs
- basenumberconverter.cs
- BitmapPalettes.cs
- EncodingNLS.cs
- IResourceProvider.cs
- RotateTransform3D.cs
- SequenceNumber.cs
- EvidenceBase.cs
- EncryptedType.cs
- BehaviorEditorPart.cs
- Interlocked.cs
- DataContractJsonSerializerOperationBehavior.cs
- CustomError.cs
- IsolatedStorageFilePermission.cs
- propertytag.cs
- WCFModelStrings.Designer.cs
- BitVec.cs
- LineBreakRecord.cs
- NavigationProgressEventArgs.cs
- BitmapSizeOptions.cs
- Debug.cs
- EventSetter.cs
- OleDbReferenceCollection.cs
- SqlTopReducer.cs
- SafeFileMappingHandle.cs
- QilChoice.cs
- LOSFormatter.cs
- HwndMouseInputProvider.cs
- SecurityState.cs
- Single.cs
- PeerObject.cs
- GrammarBuilderWildcard.cs
- TextEditorContextMenu.cs
- ExpressionList.cs
- MetadataPropertyAttribute.cs
- SQLResource.cs
- Missing.cs
- XmlCharCheckingWriter.cs
- ColorContext.cs
- XmlNamespaceDeclarationsAttribute.cs
- XdrBuilder.cs
- MaskedTextProvider.cs
- DataControlFieldTypeEditor.cs
- DataGridViewControlCollection.cs
- HTTP_SERVICE_CONFIG_URLACL_PARAM.cs
- EditingCommands.cs
- GradientBrush.cs
- UnknownBitmapDecoder.cs
- OdbcCommand.cs
- DesignerOptionService.cs
- CollectionViewSource.cs
- AuthenticationModulesSection.cs
- DataKeyCollection.cs
- ConfigXmlSignificantWhitespace.cs
- HwndHost.cs
- NonClientArea.cs
- HtmlContainerControl.cs