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
- WindowsIdentity.cs
- NamedPermissionSet.cs
- OleDbParameter.cs
- SiteMapDataSource.cs
- DataGridViewRow.cs
- TextDecorationCollection.cs
- ProcessHostFactoryHelper.cs
- GuidelineCollection.cs
- SID.cs
- OutputCacheProfile.cs
- GlyphsSerializer.cs
- DataGridViewButtonColumn.cs
- BaseCodePageEncoding.cs
- EntityViewContainer.cs
- CalendarDesigner.cs
- TagMapCollection.cs
- ZipIOExtraFieldElement.cs
- UrlPath.cs
- ProfileSettingsCollection.cs
- _LoggingObject.cs
- EpmSyndicationContentDeSerializer.cs
- SpellCheck.cs
- XmlSchemaSubstitutionGroup.cs
- ThrowHelper.cs
- MarkerProperties.cs
- DirectoryObjectSecurity.cs
- CommentEmitter.cs
- RegexStringValidator.cs
- ThemeableAttribute.cs
- SiteMapNodeItemEventArgs.cs
- AppSecurityManager.cs
- SqlLiftIndependentRowExpressions.cs
- ConfigXmlCDataSection.cs
- SQLBinary.cs
- CollectionAdapters.cs
- TextParaClient.cs
- coordinatorfactory.cs
- EmptyStringExpandableObjectConverter.cs
- XamlFilter.cs
- ProfilePropertySettings.cs
- DesignerLoader.cs
- DiscoveryMessageSequenceCD1.cs
- infer.cs
- DataGridViewCellCollection.cs
- BamlLocalizabilityResolver.cs
- localization.cs
- Vector3DValueSerializer.cs
- ObjectFullSpanRewriter.cs
- Matrix3DStack.cs
- EntityWithKeyStrategy.cs
- ListItemConverter.cs
- SqlServer2KCompatibilityAnnotation.cs
- TryCatch.cs
- TargetException.cs
- Accessible.cs
- KeyedHashAlgorithm.cs
- ClientSettingsSection.cs
- SerializationEventsCache.cs
- Panel.cs
- ShimAsPublicXamlType.cs
- PasswordRecovery.cs
- CompilerError.cs
- HistoryEventArgs.cs
- ResourcePropertyMemberCodeDomSerializer.cs
- DragDrop.cs
- CodeTypeReferenceExpression.cs
- BasicBrowserDialog.designer.cs
- Event.cs
- RegisterInfo.cs
- AssociatedControlConverter.cs
- AmbiguousMatchException.cs
- SqlFunctionAttribute.cs
- SessionPageStatePersister.cs
- Misc.cs
- UidManager.cs
- Brushes.cs
- SafeFileMappingHandle.cs
- TypeElementCollection.cs
- DataContractSerializerServiceBehavior.cs
- XdrBuilder.cs
- IRCollection.cs
- UserControlDesigner.cs
- ConfigXmlWhitespace.cs
- FileSystemEnumerable.cs
- FigureHelper.cs
- OSEnvironmentHelper.cs
- XmlnsPrefixAttribute.cs
- TheQuery.cs
- WSSecurityTokenSerializer.cs
- ConstraintStruct.cs
- SelectionWordBreaker.cs
- BitmapData.cs
- RenameRuleObjectDialog.Designer.cs
- SourceInterpreter.cs
- ModulesEntry.cs
- UnsafeNativeMethods.cs
- DynamicQueryableWrapper.cs
- InputProcessorProfilesLoader.cs
- RegularExpressionValidator.cs
- SoapReflector.cs