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
- SqlAliasesReferenced.cs
- SoapHeaderAttribute.cs
- SchemaCollectionCompiler.cs
- PointConverter.cs
- ParsedRoute.cs
- StrokeCollection2.cs
- ValueType.cs
- WebReferencesBuildProvider.cs
- TypeBuilder.cs
- XmlSchemaSimpleContent.cs
- DnsEndpointIdentity.cs
- RotationValidation.cs
- SafeRsaProviderHandle.cs
- ButtonBaseAutomationPeer.cs
- HttpResponseHeader.cs
- MatchAllMessageFilter.cs
- CollectionBuilder.cs
- Hex.cs
- HttpFileCollectionBase.cs
- HostingEnvironment.cs
- SqlBooleanizer.cs
- SafeNativeMethodsMilCoreApi.cs
- HwndSourceKeyboardInputSite.cs
- EntityContainer.cs
- EnumValidator.cs
- WebAdminConfigurationHelper.cs
- ServicePerformanceCounters.cs
- Random.cs
- OptimisticConcurrencyException.cs
- ParentControlDesigner.cs
- DoubleLinkListEnumerator.cs
- PropertyStore.cs
- Underline.cs
- ErrorHandler.cs
- FileAccessException.cs
- StreamSecurityUpgradeInitiatorBase.cs
- FormViewUpdateEventArgs.cs
- NameGenerator.cs
- XmlRawWriterWrapper.cs
- DirectionalLight.cs
- SecurityKeyUsage.cs
- VersionValidator.cs
- RtfToken.cs
- SQLInt16Storage.cs
- EntityContainer.cs
- XhtmlConformanceSection.cs
- DragCompletedEventArgs.cs
- VirtualPathProvider.cs
- AtomServiceDocumentSerializer.cs
- SQLBinaryStorage.cs
- HttpCachePolicy.cs
- NativeActivityFaultContext.cs
- Vector3DConverter.cs
- RangeExpression.cs
- QilGeneratorEnv.cs
- XmlSchemaSequence.cs
- CodeTypeParameter.cs
- AsymmetricCryptoHandle.cs
- Version.cs
- TreeViewDataItemAutomationPeer.cs
- GeneratedView.cs
- ListViewGroupItemCollection.cs
- Intellisense.cs
- DataGridViewTextBoxEditingControl.cs
- HostProtectionPermission.cs
- FontFaceLayoutInfo.cs
- EntitySqlException.cs
- BooleanFacetDescriptionElement.cs
- RayMeshGeometry3DHitTestResult.cs
- RadioButton.cs
- HttpStreamMessage.cs
- TraceSwitch.cs
- RowToParametersTransformer.cs
- _ContextAwareResult.cs
- BaseResourcesBuildProvider.cs
- HyperlinkAutomationPeer.cs
- RegexWorker.cs
- EncoderNLS.cs
- SqlServices.cs
- WizardPanelChangingEventArgs.cs
- DataGridViewToolTip.cs
- Privilege.cs
- Fonts.cs
- FileLoadException.cs
- DropTarget.cs
- EntitySet.cs
- UnSafeCharBuffer.cs
- NativeMethods.cs
- Transform3DGroup.cs
- MessageSecurityProtocol.cs
- AddInAdapter.cs
- MessageBox.cs
- SponsorHelper.cs
- XmlTextWriter.cs
- SystemSounds.cs
- ThrowHelper.cs
- AtomMaterializerLog.cs
- GenericEnumConverter.cs
- FixedDSBuilder.cs
- Shape.cs