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
- TreeNodeBinding.cs
- SettingsContext.cs
- ExpressionEditorAttribute.cs
- LinkButton.cs
- ValueConversionAttribute.cs
- RightsManagementEncryptionTransform.cs
- DataGridView.cs
- FixedSOMSemanticBox.cs
- ComponentResourceManager.cs
- LinkDescriptor.cs
- ConstraintStruct.cs
- LinkTarget.cs
- XmlSchemaInferenceException.cs
- OpenTypeLayoutCache.cs
- SqlMethods.cs
- HuffmanTree.cs
- DelayLoadType.cs
- DataGridView.cs
- CompilerGlobalScopeAttribute.cs
- PhysicalOps.cs
- FileNameEditor.cs
- WebPartAuthorizationEventArgs.cs
- SqlClientWrapperSmiStream.cs
- TypeExtensionConverter.cs
- ManipulationDeltaEventArgs.cs
- IisTraceWebEventProvider.cs
- InsufficientMemoryException.cs
- ILGenerator.cs
- DataConnectionHelper.cs
- ThicknessKeyFrameCollection.cs
- XmlNullResolver.cs
- UnsafeNativeMethods.cs
- LinkButton.cs
- X509Certificate2Collection.cs
- Soap12ServerProtocol.cs
- MenuDesigner.cs
- SmtpFailedRecipientsException.cs
- ChangeInterceptorAttribute.cs
- ToolStripContextMenu.cs
- PackageProperties.cs
- EntitySqlException.cs
- DataBindingHandlerAttribute.cs
- __Filters.cs
- SystemSounds.cs
- RegisteredScript.cs
- VirtualizingPanel.cs
- X509ThumbprintKeyIdentifierClause.cs
- ReadOnlyMetadataCollection.cs
- TagElement.cs
- SiteOfOriginContainer.cs
- SurrogateSelector.cs
- WorkflowPersistenceContext.cs
- CFGGrammar.cs
- dataprotectionpermission.cs
- ActivityScheduledRecord.cs
- EntityDataSourceWrapper.cs
- OleDbParameterCollection.cs
- FlowLayoutPanel.cs
- thaishape.cs
- ToolboxItemFilterAttribute.cs
- XpsSerializationManagerAsync.cs
- FrameworkElementFactoryMarkupObject.cs
- CryptoStream.cs
- InvalidFilterCriteriaException.cs
- RepeatBehaviorConverter.cs
- GridViewRow.cs
- Rectangle.cs
- HashHelper.cs
- ToolConsole.cs
- MenuItem.cs
- SettingsPropertyNotFoundException.cs
- ConditionalExpression.cs
- FontFamily.cs
- EpmSyndicationContentDeSerializer.cs
- SmiXetterAccessMap.cs
- SymbolPair.cs
- TransformConverter.cs
- MimeReturn.cs
- CodeDomSerializationProvider.cs
- XmlSchemaSimpleContentRestriction.cs
- RequestBringIntoViewEventArgs.cs
- DetailsViewUpdateEventArgs.cs
- ByteStack.cs
- BufferedWebEventProvider.cs
- FilterQuery.cs
- AsyncCompletedEventArgs.cs
- BinaryConverter.cs
- WsdlHelpGeneratorElement.cs
- SqlGenericUtil.cs
- SharedConnectionListener.cs
- FileRecordSequenceCompletedAsyncResult.cs
- PassportAuthentication.cs
- ExecutorLocksHeldException.cs
- DictionaryKeyPropertyAttribute.cs
- _Semaphore.cs
- ChannelFactoryBase.cs
- QueryExpr.cs
- InternalsVisibleToAttribute.cs
- MethodToken.cs
- DataGridViewComboBoxEditingControl.cs