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
- PerformanceCounterPermissionAttribute.cs
- RSAOAEPKeyExchangeFormatter.cs
- RadioButtonPopupAdapter.cs
- ValueTypeFixupInfo.cs
- Dump.cs
- ToolStripContentPanelRenderEventArgs.cs
- ResolvedKeyFrameEntry.cs
- ListItemParagraph.cs
- SqlTriggerAttribute.cs
- IApplicationTrustManager.cs
- SqlServer2KCompatibilityAnnotation.cs
- SerTrace.cs
- XmlLoader.cs
- CompilationUnit.cs
- newitemfactory.cs
- TemplateKeyConverter.cs
- PermissionSetEnumerator.cs
- ExpressionPrefixAttribute.cs
- DataServiceConfiguration.cs
- ResourceReferenceExpressionConverter.cs
- DescendantQuery.cs
- DesigntimeLicenseContext.cs
- ImageListUtils.cs
- Site.cs
- MasterPage.cs
- Subset.cs
- SessionStateItemCollection.cs
- AnimationTimeline.cs
- EventWaitHandle.cs
- ListViewInsertionMark.cs
- BaseTemplateParser.cs
- TextParagraphView.cs
- SyntaxCheck.cs
- RowUpdatedEventArgs.cs
- StringUtil.cs
- HashHelper.cs
- ObjectQueryProvider.cs
- ListViewGroupConverter.cs
- UnsafeNativeMethods.cs
- SafeJobHandle.cs
- WindowsSolidBrush.cs
- OrderByQueryOptionExpression.cs
- CfgParser.cs
- AssemblyResourceLoader.cs
- CreateUserWizard.cs
- COM2FontConverter.cs
- DurableEnlistmentState.cs
- UpdateProgress.cs
- RolePrincipal.cs
- SetStateEventArgs.cs
- SafeEventLogWriteHandle.cs
- TempFiles.cs
- UInt64Converter.cs
- Scene3D.cs
- LoginCancelEventArgs.cs
- ProjectedSlot.cs
- QueryCacheKey.cs
- DesignerDataConnection.cs
- CodeLinePragma.cs
- MetricEntry.cs
- ProfileSection.cs
- UriTemplateQueryValue.cs
- CodeBlockBuilder.cs
- SystemTcpStatistics.cs
- MsmqElementBase.cs
- SingleObjectCollection.cs
- XhtmlBasicSelectionListAdapter.cs
- StaticSiteMapProvider.cs
- WebPartCatalogCloseVerb.cs
- Pen.cs
- ButtonFieldBase.cs
- DataGridViewBand.cs
- Token.cs
- RewritingPass.cs
- QueryGeneratorBase.cs
- EditingScopeUndoUnit.cs
- CodeSnippetExpression.cs
- WebBrowserProgressChangedEventHandler.cs
- ButtonRenderer.cs
- XsdBuildProvider.cs
- SchemaConstraints.cs
- UiaCoreApi.cs
- WindowsTab.cs
- TiffBitmapEncoder.cs
- NavigationEventArgs.cs
- DATA_BLOB.cs
- XmlNamespaceDeclarationsAttribute.cs
- TextElementCollectionHelper.cs
- URLMembershipCondition.cs
- VisualCollection.cs
- Brushes.cs
- XmlSchemaAny.cs
- MetadataHelper.cs
- HttpWrapper.cs
- UserNameServiceElement.cs
- SqlParameter.cs
- CollectionConverter.cs
- DummyDataSource.cs
- SharedUtils.cs
- TextDecorationCollection.cs