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
- InvokeWebServiceDesigner.cs
- Merger.cs
- CollectionChangeEventArgs.cs
- ListViewTableRow.cs
- TableCellsCollectionEditor.cs
- ResourceWriter.cs
- _IPv4Address.cs
- SystemException.cs
- OleDbFactory.cs
- LoginName.cs
- GridViewRowPresenterBase.cs
- RuleElement.cs
- DescendantQuery.cs
- Memoizer.cs
- XPathAncestorQuery.cs
- DesignerAutoFormat.cs
- UIPermission.cs
- SafeNativeMemoryHandle.cs
- RelationshipEndCollection.cs
- HttpClientCertificate.cs
- TemplateAction.cs
- AnimationLayer.cs
- ContextMenuAutomationPeer.cs
- LightweightCodeGenerator.cs
- DiscoveryClientDocuments.cs
- EntityDataSourceUtil.cs
- Int16Converter.cs
- DrawingContextWalker.cs
- ComPersistableTypeElement.cs
- WebCodeGenerator.cs
- ToolStripSeparator.cs
- SqlClientPermission.cs
- DataServiceProviderMethods.cs
- SessionSwitchEventArgs.cs
- dbdatarecord.cs
- XpsFilter.cs
- OuterGlowBitmapEffect.cs
- TextTrailingWordEllipsis.cs
- WebPartExportVerb.cs
- SerializationFieldInfo.cs
- BooleanExpr.cs
- PtsHost.cs
- TextRenderer.cs
- ChangeProcessor.cs
- SpeechSynthesizer.cs
- CustomErrorsSectionWrapper.cs
- ColumnMapVisitor.cs
- MetadataUtilsSmi.cs
- StrokeSerializer.cs
- WebExceptionStatus.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- Evidence.cs
- OleDbParameter.cs
- WeakReferenceKey.cs
- EffectiveValueEntry.cs
- SoapWriter.cs
- GenerateTemporaryTargetAssembly.cs
- FloatSumAggregationOperator.cs
- SqlCommand.cs
- AnimationLayer.cs
- TraceUtils.cs
- PreservationFileReader.cs
- FormViewDeletedEventArgs.cs
- DrawingCollection.cs
- RequestCache.cs
- CapiNative.cs
- MediaCommands.cs
- ToolStripControlHost.cs
- WindowsToolbarAsMenu.cs
- XmlMapping.cs
- QilTargetType.cs
- UnsignedPublishLicense.cs
- AppDomainUnloadedException.cs
- HttpDictionary.cs
- LogStore.cs
- Classification.cs
- WinEventTracker.cs
- QuaternionAnimation.cs
- MemberCollection.cs
- OleDbPermission.cs
- MemberPath.cs
- StorageComplexTypeMapping.cs
- ReadOnlyAttribute.cs
- FastEncoder.cs
- TransformedBitmap.cs
- WebPartEditorOkVerb.cs
- DetailsViewModeEventArgs.cs
- TransactionScope.cs
- MatrixTransform.cs
- XmlDictionaryReader.cs
- Setter.cs
- OleServicesContext.cs
- MdImport.cs
- CurrencyWrapper.cs
- DateTimeOffset.cs
- FileSystemEventArgs.cs
- FixedTextView.cs
- XmlEntity.cs
- SqlDataSourceEnumerator.cs
- ParentUndoUnit.cs