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
- PointKeyFrameCollection.cs
- _SslState.cs
- login.cs
- OleDbMetaDataFactory.cs
- SiteIdentityPermission.cs
- ListViewGroupItemCollection.cs
- WebHttpBindingCollectionElement.cs
- LabelDesigner.cs
- RuntimeArgumentHandle.cs
- SqlEnums.cs
- DbFunctionCommandTree.cs
- Vector3DKeyFrameCollection.cs
- TabControl.cs
- OleDbParameter.cs
- _BasicClient.cs
- WebPart.cs
- SmtpTransport.cs
- ResourcesGenerator.cs
- EmptyElement.cs
- BindingContext.cs
- DocComment.cs
- AdministrationHelpers.cs
- ListArgumentProvider.cs
- SqlHelper.cs
- ListViewDeleteEventArgs.cs
- ImageAttributes.cs
- XmlUtilWriter.cs
- WindowProviderWrapper.cs
- XD.cs
- FormClosedEvent.cs
- ToolStripRenderer.cs
- TrackingProfile.cs
- SqlDataSourceQueryEditor.cs
- AnonymousIdentificationSection.cs
- NotifyCollectionChangedEventArgs.cs
- _WinHttpWebProxyDataBuilder.cs
- Process.cs
- BamlRecordReader.cs
- DataPagerFieldCommandEventArgs.cs
- SingleSelectRootGridEntry.cs
- ApplicationSecurityInfo.cs
- ByteAnimationBase.cs
- SiteOfOriginContainer.cs
- LayoutEngine.cs
- XmlUrlResolver.cs
- RightsManagementEncryptionTransform.cs
- XmlQueryRuntime.cs
- TypeTypeConverter.cs
- SettingsBindableAttribute.cs
- MachineKeySection.cs
- DecoderFallbackWithFailureFlag.cs
- BinHexDecoder.cs
- ActivityXamlServices.cs
- LineBreak.cs
- ToolZone.cs
- RightsManagementEncryptedStream.cs
- BinHexEncoder.cs
- ProviderBase.cs
- SemaphoreSlim.cs
- InvalidContentTypeException.cs
- ToolStripItemEventArgs.cs
- ErrorTolerantObjectWriter.cs
- HiddenFieldDesigner.cs
- Part.cs
- XmlEnumAttribute.cs
- SqlEnums.cs
- DataListCommandEventArgs.cs
- ExpressionParser.cs
- DiagnosticsConfiguration.cs
- counter.cs
- StorageSetMapping.cs
- OlePropertyStructs.cs
- CodeAttributeArgument.cs
- VisualBasicSettings.cs
- _Semaphore.cs
- FormView.cs
- Point4D.cs
- SoapEnumAttribute.cs
- SqlCommand.cs
- XhtmlTextWriter.cs
- iisPickupDirectory.cs
- MethodToken.cs
- ZipIOExtraField.cs
- DBDataPermissionAttribute.cs
- NavigationService.cs
- XPathBinder.cs
- QueryUtil.cs
- InheritanceService.cs
- HttpModulesSection.cs
- XsltSettings.cs
- EventLogPropertySelector.cs
- DependencyObject.cs
- CharEntityEncoderFallback.cs
- DispatcherProcessingDisabled.cs
- FormClosedEvent.cs
- FormatConvertedBitmap.cs
- PermissionToken.cs
- AuthenticationServiceManager.cs
- XsltSettings.cs
- MenuItemBinding.cs