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
- ImageAutomationPeer.cs
- TextTreeDeleteContentUndoUnit.cs
- WebContext.cs
- Repeater.cs
- CacheMemory.cs
- AlphabetConverter.cs
- PopupRoot.cs
- BamlRecords.cs
- NumericExpr.cs
- PersistenceContextEnlistment.cs
- Label.cs
- HealthMonitoringSectionHelper.cs
- ObjectDataSourceFilteringEventArgs.cs
- QueryContinueDragEvent.cs
- ArgIterator.cs
- Marshal.cs
- SamlAssertion.cs
- RightsManagementPermission.cs
- nulltextnavigator.cs
- PixelShader.cs
- InfoCardSymmetricAlgorithm.cs
- SiteMapHierarchicalDataSourceView.cs
- SqlProviderManifest.cs
- HealthMonitoringSectionHelper.cs
- HScrollProperties.cs
- MenuRendererStandards.cs
- AssociationTypeEmitter.cs
- PathNode.cs
- StylusPoint.cs
- CollectionChangeEventArgs.cs
- CheckedListBox.cs
- XmlReflectionImporter.cs
- FlatButtonAppearance.cs
- ObjectSerializerFactory.cs
- ProcessHostConfigUtils.cs
- RuleAction.cs
- MailAddressCollection.cs
- MenuScrollingVisibilityConverter.cs
- LogicalTreeHelper.cs
- RedirectionProxy.cs
- HashSet.cs
- ObjRef.cs
- TypeViewSchema.cs
- TypeConverterAttribute.cs
- XmlCharCheckingWriter.cs
- DeclarativeCatalogPart.cs
- ActivityExecutor.cs
- CachedRequestParams.cs
- ControlBuilderAttribute.cs
- FormDocumentDesigner.cs
- securitycriticaldataformultiplegetandset.cs
- TemplateControl.cs
- Rotation3D.cs
- PointLightBase.cs
- EventMappingSettingsCollection.cs
- EdmValidator.cs
- WinEventQueueItem.cs
- BitmapMetadataBlob.cs
- ReturnType.cs
- SmiRecordBuffer.cs
- BufferedOutputStream.cs
- RangeValuePattern.cs
- HttpCookie.cs
- TraceXPathNavigator.cs
- FixedLineResult.cs
- Light.cs
- MetadataReference.cs
- UnsafeNativeMethodsMilCoreApi.cs
- ScrollBarRenderer.cs
- TransformerConfigurationWizardBase.cs
- HttpModuleActionCollection.cs
- WebPartEventArgs.cs
- DataBoundControlDesigner.cs
- XsltOutput.cs
- AvTraceDetails.cs
- UInt16.cs
- odbcmetadatafactory.cs
- BinHexEncoder.cs
- GeometryGroup.cs
- StringValidatorAttribute.cs
- Queue.cs
- BufferedGraphicsManager.cs
- CompositeDataBoundControl.cs
- IERequestCache.cs
- RegexStringValidatorAttribute.cs
- BinHexEncoder.cs
- LabelInfo.cs
- MessageDecoder.cs
- GPStream.cs
- XPathSelfQuery.cs
- DataTemplateSelector.cs
- Trace.cs
- AliasedSlot.cs
- SpanIndex.cs
- TimelineGroup.cs
- LookupBindingPropertiesAttribute.cs
- HandleCollector.cs
- ExtensionFile.cs
- OleDbSchemaGuid.cs
- SqlProcedureAttribute.cs