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
- StyleSheetRefUrlEditor.cs
- XmlSchemaNotation.cs
- ColorAnimationBase.cs
- SqlDataSourceView.cs
- AlignmentYValidation.cs
- SqlCachedBuffer.cs
- FigureParagraph.cs
- BufferModesCollection.cs
- SymbolPair.cs
- KeyConstraint.cs
- listitem.cs
- DataGridAutomationPeer.cs
- XmlCountingReader.cs
- TextFormatterContext.cs
- MethodExecutor.cs
- UnknownBitmapDecoder.cs
- Baml6Assembly.cs
- CannotUnloadAppDomainException.cs
- WebPartZoneCollection.cs
- ModifierKeysValueSerializer.cs
- SafeArrayRankMismatchException.cs
- AssociationEndMember.cs
- StorageAssociationTypeMapping.cs
- DomNameTable.cs
- DelegatingTypeDescriptionProvider.cs
- DataGridViewColumnCollectionEditor.cs
- FullTextState.cs
- WebReferenceOptions.cs
- DataGridTable.cs
- FormatConvertedBitmap.cs
- QilUnary.cs
- XslTransform.cs
- CategoryEditor.cs
- SoapFault.cs
- FixedNode.cs
- ListViewPagedDataSource.cs
- ReadOnlyNameValueCollection.cs
- StackOverflowException.cs
- COM2ColorConverter.cs
- FilterElement.cs
- Calendar.cs
- LabelLiteral.cs
- ResourceProperty.cs
- NetworkStream.cs
- XmlDocumentSerializer.cs
- DesignerVerb.cs
- QueryOutputWriterV1.cs
- ValueSerializer.cs
- TextOnlyOutput.cs
- XmlUnspecifiedAttribute.cs
- ObjectViewFactory.cs
- ReadOnlyState.cs
- WebPartMinimizeVerb.cs
- ClientSponsor.cs
- SettingsAttributes.cs
- DeferredBinaryDeserializerExtension.cs
- OuterGlowBitmapEffect.cs
- SocketPermission.cs
- SQLByteStorage.cs
- X509ChainElement.cs
- BehaviorService.cs
- SimpleLine.cs
- SqlTriggerContext.cs
- XPathDocumentBuilder.cs
- MimePart.cs
- StandardRuntimeEnumValidatorAttribute.cs
- DatagridviewDisplayedBandsData.cs
- OneToOneMappingSerializer.cs
- GlobalizationSection.cs
- Variant.cs
- UIPropertyMetadata.cs
- diagnosticsswitches.cs
- MSAAEventDispatcher.cs
- ExtentKey.cs
- TraceLog.cs
- SqlDataReader.cs
- ValidatorCompatibilityHelper.cs
- TypeElement.cs
- GetChildSubtree.cs
- DataGridViewCellParsingEventArgs.cs
- SkewTransform.cs
- Int32Converter.cs
- ConfigurationStrings.cs
- ToolStripContainerActionList.cs
- PeerResolverMode.cs
- PrintPageEvent.cs
- SynchronizedDispatch.cs
- RangeValidator.cs
- LicenseProviderAttribute.cs
- TextBox.cs
- COM2PictureConverter.cs
- MenuEventArgs.cs
- XmlSerializationWriter.cs
- SqlClientWrapperSmiStream.cs
- FileUtil.cs
- PrintPreviewControl.cs
- ServiceReference.cs
- WebHttpSecurityElement.cs
- PerformanceCounterPermissionEntry.cs
- SqlTriggerContext.cs