Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / _Semaphore.cs / 1305376 / _Semaphore.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- #pragma warning disable 618 namespace System.Net { using System; using System.Threading; using System.Security.Permissions; // used for Connection Pooling internal sealed class Semaphore : WaitHandle { internal Semaphore(int initialCount, int maxCount) : base() { lock (this) { // Handle = UnsafeNclNativeMethods.CreateSemaphore(IntPtr.Zero, initialCount, maxCount, IntPtr.Zero); } } /* // Consider removing. public Semaphore(int initialCount, int maxCount, string name) : base() { lock (this) { // */ internal bool ReleaseSemaphore() { #if DEBUG int previousCount; bool success = UnsafeNclNativeMethods.ReleaseSemaphore(Handle, 1, out previousCount); GlobalLog.Print("ReleaseSemaphore#"+ValidationHelper.HashString(this)+" success:"+success+" previousCount:"+previousCount.ToString()); return success; #else return UnsafeNclNativeMethods.ReleaseSemaphore(Handle, 1, IntPtr.Zero); #endif } /* // Consider removing. internal bool ReleaseSemaphore(int releaseCount, out int previousCount) { return UnsafeNclNativeMethods.ReleaseSemaphore(Handle, releaseCount, out previousCount); } */ } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- #pragma warning disable 618 namespace System.Net { using System; using System.Threading; using System.Security.Permissions; // used for Connection Pooling internal sealed class Semaphore : WaitHandle { internal Semaphore(int initialCount, int maxCount) : base() { lock (this) { // Handle = UnsafeNclNativeMethods.CreateSemaphore(IntPtr.Zero, initialCount, maxCount, IntPtr.Zero); } } /* // Consider removing. public Semaphore(int initialCount, int maxCount, string name) : base() { lock (this) { // */ internal bool ReleaseSemaphore() { #if DEBUG int previousCount; bool success = UnsafeNclNativeMethods.ReleaseSemaphore(Handle, 1, out previousCount); GlobalLog.Print("ReleaseSemaphore#"+ValidationHelper.HashString(this)+" success:"+success+" previousCount:"+previousCount.ToString()); return success; #else return UnsafeNclNativeMethods.ReleaseSemaphore(Handle, 1, IntPtr.Zero); #endif } /* // Consider removing. internal bool ReleaseSemaphore(int releaseCount, out int previousCount) { return UnsafeNclNativeMethods.ReleaseSemaphore(Handle, releaseCount, out previousCount); } */ } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BuildProvider.cs
- DataPager.cs
- GACIdentityPermission.cs
- ColorIndependentAnimationStorage.cs
- ApplicationSecurityInfo.cs
- FileResponseElement.cs
- TableLayoutPanelCellPosition.cs
- Semaphore.cs
- TempFiles.cs
- XmlLinkedNode.cs
- TypeForwardedToAttribute.cs
- InheritanceContextHelper.cs
- RoutedUICommand.cs
- DateTimeStorage.cs
- ColumnCollection.cs
- ToolStripOverflow.cs
- SqlCommandSet.cs
- PeerEndPoint.cs
- UrlMapping.cs
- CommandTreeTypeHelper.cs
- NextPreviousPagerField.cs
- LoadRetryStrategyFactory.cs
- UnmanagedMemoryStream.cs
- TTSEngineTypes.cs
- TextTabProperties.cs
- CodeConditionStatement.cs
- XmlILStorageConverter.cs
- PropertyInformation.cs
- ExpressionHelper.cs
- Highlights.cs
- FtpWebResponse.cs
- GridItemPatternIdentifiers.cs
- ConfigurationProviderException.cs
- MutexSecurity.cs
- SourceSwitch.cs
- DataContractSerializer.cs
- FontDialog.cs
- XmlILAnnotation.cs
- OleAutBinder.cs
- CryptoApi.cs
- RightsManagementEncryptionTransform.cs
- CompilerGlobalScopeAttribute.cs
- _HelperAsyncResults.cs
- OledbConnectionStringbuilder.cs
- TimeSpanSecondsOrInfiniteConverter.cs
- RowVisual.cs
- Int32CollectionValueSerializer.cs
- JavaScriptString.cs
- OdbcEnvironment.cs
- BaseParaClient.cs
- FragmentNavigationEventArgs.cs
- ClientTargetSection.cs
- AppDomain.cs
- InputLanguage.cs
- AddToCollection.cs
- typedescriptorpermission.cs
- UrlMappingCollection.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- MailHeaderInfo.cs
- DockingAttribute.cs
- RequestSecurityTokenSerializer.cs
- WeakReferenceKey.cs
- FacetChecker.cs
- SmiXetterAccessMap.cs
- ToolboxDataAttribute.cs
- CompoundFileStreamReference.cs
- ExpressionBuilderCollection.cs
- StateManagedCollection.cs
- AuthenticationConfig.cs
- AppSettingsExpressionBuilder.cs
- RSAOAEPKeyExchangeFormatter.cs
- FunctionUpdateCommand.cs
- SynchronizingStream.cs
- Int32CollectionConverter.cs
- QilValidationVisitor.cs
- TimeSpanStorage.cs
- TypedReference.cs
- ProjectionRewriter.cs
- WindowsFormsHostPropertyMap.cs
- DelayedRegex.cs
- SchemeSettingElement.cs
- WmpBitmapEncoder.cs
- WriteableBitmap.cs
- DrawingDrawingContext.cs
- ObfuscationAttribute.cs
- DataListComponentEditor.cs
- SolidColorBrush.cs
- RijndaelManagedTransform.cs
- WmpBitmapEncoder.cs
- SimpleTypeResolver.cs
- ProcessHostServerConfig.cs
- EnterpriseServicesHelper.cs
- CmsInterop.cs
- SystemUnicastIPAddressInformation.cs
- DesignerActionItemCollection.cs
- DBCSCodePageEncoding.cs
- NullableFloatAverageAggregationOperator.cs
- SafeCoTaskMem.cs
- TableStyle.cs
- ColumnHeader.cs