Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Net / System / Net / _Semaphore.cs / 1 / _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
- httpstaticobjectscollection.cs
- TextBreakpoint.cs
- WMIInterop.cs
- MailAddress.cs
- PagesChangedEventArgs.cs
- MetadataCache.cs
- safemediahandle.cs
- XmlNamespaceManager.cs
- XPathNodeHelper.cs
- Italic.cs
- FileFormatException.cs
- XmlSchemaDocumentation.cs
- TdsParserStateObject.cs
- OptimizedTemplateContent.cs
- mediapermission.cs
- SingleStorage.cs
- XmlNamespaceMappingCollection.cs
- _BaseOverlappedAsyncResult.cs
- PersonalizationState.cs
- ApplicationSecurityInfo.cs
- WindowsHyperlink.cs
- MultiTrigger.cs
- BaseParaClient.cs
- MulticastIPAddressInformationCollection.cs
- ObjectKeyFrameCollection.cs
- RegexWriter.cs
- ExtractedStateEntry.cs
- SoapSchemaExporter.cs
- UniqueID.cs
- ConstraintCollection.cs
- Helpers.cs
- IteratorFilter.cs
- MenuItem.cs
- OrCondition.cs
- WebPartConnectionsCancelEventArgs.cs
- arabicshape.cs
- TextRangeSerialization.cs
- XmlnsPrefixAttribute.cs
- ForceCopyBuildProvider.cs
- OperationCanceledException.cs
- BinaryEditor.cs
- DataGridrowEditEndingEventArgs.cs
- ThicknessConverter.cs
- FormParameter.cs
- AddInSegmentDirectoryNotFoundException.cs
- SecurityImpersonationBehavior.cs
- NetTcpBindingElement.cs
- StreamWriter.cs
- TimerExtension.cs
- RayHitTestParameters.cs
- TextEffect.cs
- Normalization.cs
- _HelperAsyncResults.cs
- DataObject.cs
- ParseHttpDate.cs
- Variable.cs
- HostingPreferredMapPath.cs
- Registry.cs
- XmlWriterTraceListener.cs
- PointAnimationUsingKeyFrames.cs
- UpdateTranslator.cs
- EventDescriptor.cs
- handlecollector.cs
- RefExpr.cs
- Vertex.cs
- FormViewUpdatedEventArgs.cs
- BitStack.cs
- RowType.cs
- SqlError.cs
- WebPartsPersonalizationAuthorization.cs
- DomNameTable.cs
- InvalidWMPVersionException.cs
- TableDetailsCollection.cs
- TableCellAutomationPeer.cs
- HtmlInputText.cs
- MessageEncoderFactory.cs
- FileDialog_Vista.cs
- ClientOperationFormatterProvider.cs
- IisTraceListener.cs
- RoleManagerEventArgs.cs
- StoreItemCollection.cs
- Zone.cs
- FrameworkPropertyMetadata.cs
- BitArray.cs
- UInt64Storage.cs
- RawTextInputReport.cs
- SiteMembershipCondition.cs
- X500Name.cs
- CacheChildrenQuery.cs
- ServiceContractViewControl.cs
- odbcmetadatacollectionnames.cs
- TextBreakpoint.cs
- Reference.cs
- CalendarDay.cs
- WindowsHyperlink.cs
- TrustExchangeException.cs
- HttpServerVarsCollection.cs
- ServiceOperation.cs
- RelOps.cs
- DictionarySectionHandler.cs