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
- RijndaelManagedTransform.cs
- SiteOfOriginContainer.cs
- StylusButtonEventArgs.cs
- HttpConfigurationContext.cs
- PrincipalPermission.cs
- PathParser.cs
- RequestQueue.cs
- SynchronizationLockException.cs
- ClientUrlResolverWrapper.cs
- AssertSection.cs
- DocumentApplication.cs
- Keyboard.cs
- SelectedDatesCollection.cs
- WrappedIUnknown.cs
- MbpInfo.cs
- CreateRefExpr.cs
- BackEase.cs
- HttpProfileGroupBase.cs
- WorkflowHostingEndpoint.cs
- SizeAnimationClockResource.cs
- DataSourceCache.cs
- SimpleType.cs
- ScriptModule.cs
- NameValueSectionHandler.cs
- ExtentCqlBlock.cs
- WorkflowInspectionServices.cs
- DocumentStatusResources.cs
- PeerName.cs
- StrokeFIndices.cs
- HtmlShimManager.cs
- WebPartEditorOkVerb.cs
- InvalidPropValue.cs
- XPathSelfQuery.cs
- OverrideMode.cs
- OrderingExpression.cs
- WebPartUserCapability.cs
- PublisherIdentityPermission.cs
- DBDataPermissionAttribute.cs
- ArgIterator.cs
- TerminatorSinks.cs
- AxisAngleRotation3D.cs
- Graphics.cs
- Button.cs
- PropertyTabAttribute.cs
- Drawing.cs
- SqlDataRecord.cs
- OletxVolatileEnlistment.cs
- StructuredCompositeActivityDesigner.cs
- SQLChars.cs
- SelectionHighlightInfo.cs
- Message.cs
- VirtualizingPanel.cs
- ExpressionParser.cs
- NamespaceEmitter.cs
- HuffModule.cs
- NameValueSectionHandler.cs
- SQLCharsStorage.cs
- StreamWriter.cs
- KoreanLunisolarCalendar.cs
- LogEntrySerialization.cs
- Claim.cs
- XslTransform.cs
- BoundColumn.cs
- ApplicationServiceManager.cs
- SharedStatics.cs
- MatrixAnimationBase.cs
- InvalidProgramException.cs
- ChildTable.cs
- OptimizedTemplateContent.cs
- AnnotationResourceChangedEventArgs.cs
- TrackingLocation.cs
- DocumentCollection.cs
- ResourceDescriptionAttribute.cs
- UrlPropertyAttribute.cs
- CreateUserErrorEventArgs.cs
- ConnectionManager.cs
- documentsequencetextcontainer.cs
- XmlIlTypeHelper.cs
- SelectionBorderGlyph.cs
- ErrorEventArgs.cs
- HitTestWithPointDrawingContextWalker.cs
- ConstructorExpr.cs
- HtmlElementErrorEventArgs.cs
- ConfigurationManagerHelperFactory.cs
- DBConnectionString.cs
- ColumnHeader.cs
- DataBindEngine.cs
- StorageComplexPropertyMapping.cs
- TextStore.cs
- XPathChildIterator.cs
- QilParameter.cs
- NavigationPropertyEmitter.cs
- ZipIORawDataFileBlock.cs
- tibetanshape.cs
- DataGridViewCellMouseEventArgs.cs
- StandardTransformFactory.cs
- PointAnimationUsingKeyFrames.cs
- CursorInteropHelper.cs
- WizardStepBase.cs
- CustomErrorsSectionWrapper.cs