Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / Channels / CommunicationObjectManager.cs / 1 / CommunicationObjectManager.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Channels { using System.Diagnostics; using System.ServiceModel; using System.Collections.Generic; using System.Collections; internal class CommunicationObjectManager: LifetimeManager where ItemType : class, ICommunicationObject { bool inputClosed; Hashtable table; public CommunicationObjectManager(object mutex) : base(mutex) { this.table = new Hashtable(); } public void Add(ItemType item) { bool added = false; lock (this.ThisLock) { if (this.State == LifetimeState.Opened && !this.inputClosed) { if (this.table.ContainsKey(item)) return; this.table.Add(item, item); base.IncrementBusyCountWithoutLock(); item.Closed += this.OnItemClosed; added = true; } } if (!added) { item.Abort(); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ObjectDisposedException(this.GetType().ToString())); } } public void CloseInput() { //Abort can reenter this call as a result of //close timeout, Closing input twice is not a //FailFast case. this.inputClosed = true; } public void DecrementActivityCount() { this.DecrementBusyCount(); } public void IncrementActivityCount() { this.IncrementBusyCount(); } void OnItemClosed(object sender, EventArgs args) { this.Remove((ItemType)sender); } public void Remove(ItemType item) { lock (this.ThisLock) { if (!this.table.ContainsKey(item)) return; this.table.Remove(item); } item.Closed -= this.OnItemClosed; base.DecrementBusyCount(); } public ItemType[] ToArray() { lock (this.ThisLock) { int index = 0; ItemType[] items = new ItemType[this.table.Keys.Count]; foreach(ItemType item in this.table.Keys) items[index++] = item; return items; } } } } // 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
- XmlUtf8RawTextWriter.cs
- SecurityKeyUsage.cs
- FreezableCollection.cs
- GraphicsState.cs
- DataObjectMethodAttribute.cs
- ExpressionPrinter.cs
- ServiceParser.cs
- WebScriptEndpoint.cs
- PersistenceIOParticipant.cs
- AnyAllSearchOperator.cs
- ElementUtil.cs
- MultiByteCodec.cs
- MemberMaps.cs
- SqlAggregateChecker.cs
- SerializationAttributes.cs
- CustomError.cs
- ConstructorNeedsTagAttribute.cs
- EventLogException.cs
- Currency.cs
- SqlException.cs
- WorkflowInspectionServices.cs
- ViewStateException.cs
- SecurityRuntime.cs
- SQLString.cs
- GeneralTransform2DTo3DTo2D.cs
- FlagsAttribute.cs
- FlowPosition.cs
- SizeAnimation.cs
- SmiEventSink_DeferedProcessing.cs
- InvalidEnumArgumentException.cs
- ResXResourceReader.cs
- GcHandle.cs
- AsyncPostBackTrigger.cs
- StrokeFIndices.cs
- PathSegment.cs
- WebBrowserBase.cs
- Trustee.cs
- VirtualPath.cs
- StaticSiteMapProvider.cs
- LambdaCompiler.Expressions.cs
- DataGridViewMethods.cs
- GeneralTransform3DTo2DTo3D.cs
- GridViewSortEventArgs.cs
- AsmxEndpointPickerExtension.cs
- MetadataItemEmitter.cs
- CommandEventArgs.cs
- WindowsAuthenticationModule.cs
- ColorDialog.cs
- OneWayBindingElement.cs
- SqlCharStream.cs
- GenericTransactionFlowAttribute.cs
- Binding.cs
- LingerOption.cs
- SystemInfo.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- _Events.cs
- MasterPage.cs
- StrongNameIdentityPermission.cs
- SoapReflector.cs
- ReliableRequestSessionChannel.cs
- HttpServerUtilityBase.cs
- Point4DConverter.cs
- ReadOnlyDictionary.cs
- ScrollBar.cs
- EntityDataSourceViewSchema.cs
- XmlDataLoader.cs
- CompilerResults.cs
- TaskFormBase.cs
- WebPartZone.cs
- TCPClient.cs
- PropertyMappingExceptionEventArgs.cs
- MouseEventArgs.cs
- RoutingChannelExtension.cs
- TabControl.cs
- CharUnicodeInfo.cs
- WebConfigurationFileMap.cs
- DomainConstraint.cs
- Parallel.cs
- IISMapPath.cs
- SharedTcpTransportManager.cs
- XmlNavigatorFilter.cs
- ThreadAbortException.cs
- AutomationElementCollection.cs
- WindowsFormsHelpers.cs
- GroupBox.cs
- SqlDataSourceDesigner.cs
- AsyncPostBackTrigger.cs
- PropertyFilterAttribute.cs
- Peer.cs
- TextServicesProperty.cs
- CatalogZone.cs
- FamilyTypefaceCollection.cs
- DocumentApplication.cs
- SignatureDescription.cs
- BinaryReader.cs
- xmlfixedPageInfo.cs
- FunctionDetailsReader.cs
- WsdlWriter.cs
- GifBitmapEncoder.cs
- EventData.cs