Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / ConnectionPoolManager.cs / 1 / ConnectionPoolManager.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net { using System; using System.Collections; using System.Diagnostics; using System.Security; using System.Security.Permissions; using System.Threading; using System.Globalization; internal class ConnectionPoolManager { private static Hashtable m_ConnectionPools = new Hashtable(); // Hashtable used for connection pools private static object s_InternalSyncObject; private ConnectionPoolManager() { } private static object InternalSyncObject { get { if (s_InternalSyncObject == null) { object o = new Object(); Interlocked.CompareExchange(ref s_InternalSyncObject, o, null); } return s_InternalSyncObject; } } /*internal static ConnectionPool[] ConnectionPools { get { lock(InternalSyncObject) { ConnectionPool [] connectionPools = new ConnectionPool[m_ConnectionPools.Count]; m_ConnectionPools.CopyTo(connectionPools, 0); return connectionPools; } } } */ private static string GenerateKey(string hostName, int port, string groupName) { return hostName+"\r"+port.ToString(NumberFormatInfo.InvariantInfo)+"\r"+groupName; } internal static ConnectionPool GetConnectionPool(ServicePoint servicePoint, string groupName, CreateConnectionDelegate createConnectionCallback) { string key = GenerateKey(servicePoint.Host, servicePoint.Port, groupName); lock(InternalSyncObject) { ConnectionPool connectionPool = (ConnectionPool) m_ConnectionPools[key]; if (connectionPool == null) { connectionPool = new ConnectionPool(servicePoint, servicePoint.ConnectionLimit, 0, servicePoint.MaxIdleTime, createConnectionCallback); m_ConnectionPools[key] = connectionPool; } return connectionPool; } } /* internal static ConnectionPool GetConnectionPool(string hostName, int port, string groupName, CreateConnectionDelegate createConnectionCallback) { string key = hostName + "\r" + port.ToString(NumberFormatInfo.InvariantInfo) + "\r" + groupName; lock(InternalSyncObject) { ConnectionPool connectionPool = (ConnectionPool) m_ConnectionPools[key]; if (connectionPool == null) { ServicePoint servicePoint = ServicePointManager.FindServicePoint(new Uri("sockets://" + hostName + ":" + port.ToString(NumberFormatInfo.InvariantInfo)), null); connectionPool = new ConnectionPool(servicePoint, m_DefaultMaxPool, 0, servicePoint.MaxIdleTime, createConnectionCallback); m_ConnectionPools[key] = connectionPool; } return connectionPool; } } */ internal static bool RemoveConnectionPool(ServicePoint servicePoint, string groupName) { string key = GenerateKey(servicePoint.Host, servicePoint.Port, groupName); lock(InternalSyncObject) { ConnectionPool connectionPool = (ConnectionPool)(m_ConnectionPools[key]); if(connectionPool != null) { m_ConnectionPools[key] = null; m_ConnectionPools.Remove(key); return true; } } return false; } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PassportAuthenticationEventArgs.cs
- ColorPalette.cs
- HtmlControl.cs
- RegionData.cs
- ContextStack.cs
- DataObjectEventArgs.cs
- UInt64Storage.cs
- BindingNavigator.cs
- NativeMethods.cs
- precedingquery.cs
- BitmapEffectGeneralTransform.cs
- VoiceChangeEventArgs.cs
- HwndHost.cs
- AnnotationComponentManager.cs
- RtType.cs
- DisplayInformation.cs
- NativeBuffer.cs
- EntitySqlQueryState.cs
- ProviderIncompatibleException.cs
- sqlstateclientmanager.cs
- InstanceView.cs
- XmlNotation.cs
- SinglePageViewer.cs
- IncrementalCompileAnalyzer.cs
- PolicyValidationException.cs
- RawStylusActions.cs
- BaseConfigurationRecord.cs
- XPathParser.cs
- DecimalAnimation.cs
- MetadataUtilsSmi.cs
- GlyphRun.cs
- EventManager.cs
- TagMapInfo.cs
- ValueExpressions.cs
- SqlDataSourceWizardForm.cs
- WebEventCodes.cs
- TextBoxAutomationPeer.cs
- FeatureManager.cs
- NameValueFileSectionHandler.cs
- DesignOnlyAttribute.cs
- Soap.cs
- TextEditorMouse.cs
- XmlUTF8TextReader.cs
- HwndKeyboardInputProvider.cs
- WindowsSpinner.cs
- LocalizationComments.cs
- DataGridTablesFactory.cs
- XmlSchemaValidator.cs
- RowToFieldTransformer.cs
- FontFamily.cs
- DropDownList.cs
- Vector3DKeyFrameCollection.cs
- _SSPISessionCache.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- AssociatedControlConverter.cs
- NetTcpBinding.cs
- TypeUnloadedException.cs
- BamlResourceDeserializer.cs
- ObjectKeyFrameCollection.cs
- Crc32Helper.cs
- RecordConverter.cs
- CultureInfoConverter.cs
- DataGridViewAccessibleObject.cs
- PasswordTextNavigator.cs
- SQlBooleanStorage.cs
- XpsFilter.cs
- Int64.cs
- DeviceFiltersSection.cs
- KnownColorTable.cs
- MD5CryptoServiceProvider.cs
- FormatException.cs
- XamlToRtfWriter.cs
- SHA384.cs
- TrustSection.cs
- EntityDataSourceStatementEditor.cs
- AcceleratedTokenProviderState.cs
- NameValueFileSectionHandler.cs
- DeadCharTextComposition.cs
- DatePickerTextBox.cs
- WindowPatternIdentifiers.cs
- SQLRoleProvider.cs
- OptimisticConcurrencyException.cs
- ResourceDescriptionAttribute.cs
- EventHandlerList.cs
- FileUpload.cs
- ScriptDescriptor.cs
- SharedPerformanceCounter.cs
- NativeCppClassAttribute.cs
- SamlNameIdentifierClaimResource.cs
- FixedBufferAttribute.cs
- WebPartChrome.cs
- RadioButtonPopupAdapter.cs
- SetterBase.cs
- BuildTopDownAttribute.cs
- RtfFormatStack.cs
- DeploymentSection.cs
- CodeConstructor.cs
- Clause.cs
- StreamedWorkflowDefinitionContext.cs
- AnnotationComponentChooser.cs