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
- Hash.cs
- ListViewItemEventArgs.cs
- InlineCollection.cs
- ScaleTransform3D.cs
- AssertSection.cs
- ContentOperations.cs
- FrameworkContentElement.cs
- CqlLexer.cs
- WindowPatternIdentifiers.cs
- UnauthorizedAccessException.cs
- OdbcRowUpdatingEvent.cs
- ErrorView.xaml.cs
- ConfigurationSection.cs
- _ListenerRequestStream.cs
- NavigationEventArgs.cs
- TagNameToTypeMapper.cs
- MenuScrollingVisibilityConverter.cs
- WpfXamlMember.cs
- ExtensionQuery.cs
- DelegateInArgument.cs
- TextTreeUndoUnit.cs
- TextBoxAutoCompleteSourceConverter.cs
- DateRangeEvent.cs
- Keywords.cs
- WindowsGraphicsCacheManager.cs
- PrinterUnitConvert.cs
- RoutedEvent.cs
- FunctionCommandText.cs
- SQLSingleStorage.cs
- StateMachineHelpers.cs
- CommonBehaviorsSection.cs
- UdpDuplexChannel.cs
- StoryFragments.cs
- XamlValidatingReader.cs
- ConfigurationPropertyCollection.cs
- FloaterParagraph.cs
- CodeBlockBuilder.cs
- Classification.cs
- MergeFailedEvent.cs
- RectIndependentAnimationStorage.cs
- XmlILOptimizerVisitor.cs
- ObjectHelper.cs
- PerformanceCounterPermissionEntryCollection.cs
- DependencyProperty.cs
- GeneralEndpointIdentity.cs
- IisTraceListener.cs
- SelectionItemProviderWrapper.cs
- InstanceDescriptor.cs
- SQLChars.cs
- TempFiles.cs
- TextDpi.cs
- Subtract.cs
- LocalizationParserHooks.cs
- MouseOverProperty.cs
- FileUtil.cs
- AnalyzedTree.cs
- PriorityQueue.cs
- XmlSchemaAttributeGroupRef.cs
- RSAPKCS1SignatureFormatter.cs
- PauseStoryboard.cs
- PatternMatcher.cs
- WebConfigurationFileMap.cs
- SafeProcessHandle.cs
- DesignerActionVerbItem.cs
- SetStateEventArgs.cs
- ColorTypeConverter.cs
- Directory.cs
- XmlBindingWorker.cs
- SchemaMapping.cs
- HttpsHostedTransportConfiguration.cs
- HandleCollector.cs
- HtmlElementCollection.cs
- HttpCachePolicyElement.cs
- HotCommands.cs
- SafeNativeMethods.cs
- CodeMemberField.cs
- Propagator.JoinPropagator.cs
- HtmlEmptyTagControlBuilder.cs
- PropertyInfoSet.cs
- FunctionImportElement.cs
- ImageDesigner.cs
- SqlInternalConnectionTds.cs
- SqlDataSourceConfigureFilterForm.cs
- Context.cs
- MessageBox.cs
- AppSettingsExpressionBuilder.cs
- DescendantBaseQuery.cs
- SqlBuilder.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- RegexWorker.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- ImageField.cs
- SecurityKeyType.cs
- DBConnectionString.cs
- PagerSettings.cs
- CacheManager.cs
- TraversalRequest.cs
- EntityDataSourceSelectedEventArgs.cs
- ButtonBaseDesigner.cs
- DurationConverter.cs