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
- FontFamily.cs
- RowType.cs
- CodeThrowExceptionStatement.cs
- PropertyItem.cs
- CompiledIdentityConstraint.cs
- GAC.cs
- RequestBringIntoViewEventArgs.cs
- EntityViewGenerationAttribute.cs
- SHA1Cng.cs
- RectAnimationUsingKeyFrames.cs
- EventHandlerList.cs
- FixedSOMLineRanges.cs
- OutputCacheSection.cs
- AppSecurityManager.cs
- CapabilitiesState.cs
- Aggregates.cs
- Registry.cs
- AspNetSynchronizationContext.cs
- SerializationInfo.cs
- GetReadStreamResult.cs
- ChildTable.cs
- XmlEncoding.cs
- DropDownButton.cs
- AdjustableArrowCap.cs
- FlowDocumentReaderAutomationPeer.cs
- ConfigurationErrorsException.cs
- ProvidersHelper.cs
- OperationCanceledException.cs
- SendMailErrorEventArgs.cs
- EntityViewGenerationConstants.cs
- ContractCodeDomInfo.cs
- PlatformNotSupportedException.cs
- XsdDateTime.cs
- GridViewRowEventArgs.cs
- PageContent.cs
- FixedSOMSemanticBox.cs
- SqlDataSourceSelectingEventArgs.cs
- BindUriHelper.cs
- BulletDecorator.cs
- DataIdProcessor.cs
- ProfileSettingsCollection.cs
- ProfileProvider.cs
- RowUpdatingEventArgs.cs
- GetPolicyDetailsRequest.cs
- GeneratedCodeAttribute.cs
- DragCompletedEventArgs.cs
- CodePrimitiveExpression.cs
- SpeakCompletedEventArgs.cs
- ProvideValueServiceProvider.cs
- UnionCqlBlock.cs
- SafeCryptContextHandle.cs
- GcHandle.cs
- CodeGroup.cs
- WindowsEditBoxRange.cs
- ToolStripItemImageRenderEventArgs.cs
- EmulateRecognizeCompletedEventArgs.cs
- ColumnClickEvent.cs
- SspiSafeHandles.cs
- RefreshEventArgs.cs
- DesignerActionService.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- AssemblyBuilder.cs
- DefaultTraceListener.cs
- QueryAccessibilityHelpEvent.cs
- Int32CAMarshaler.cs
- LocalServiceSecuritySettings.cs
- OutputCacheModule.cs
- OleDbParameter.cs
- HTTPNotFoundHandler.cs
- VolatileEnlistmentMultiplexing.cs
- StorageSetMapping.cs
- AsmxEndpointPickerExtension.cs
- PublisherMembershipCondition.cs
- Propagator.Evaluator.cs
- _BufferOffsetSize.cs
- FontNameEditor.cs
- FlowDocumentReaderAutomationPeer.cs
- AccessibleObject.cs
- TemplateControlCodeDomTreeGenerator.cs
- Converter.cs
- InternalUserCancelledException.cs
- TimeZone.cs
- AppSettingsExpressionBuilder.cs
- MethodBuilder.cs
- ByteConverter.cs
- Emitter.cs
- StoreAnnotationsMap.cs
- EntityConnectionStringBuilder.cs
- Ray3DHitTestResult.cs
- DummyDataSource.cs
- DataSourceProvider.cs
- ButtonColumn.cs
- BooleanProjectedSlot.cs
- PrinterUnitConvert.cs
- ClipboardProcessor.cs
- ComboBoxAutomationPeer.cs
- RadioButton.cs
- Pair.cs
- DelegatingTypeDescriptionProvider.cs
- __FastResourceComparer.cs