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
- WorkflowHostingResponseContext.cs
- XmlSignificantWhitespace.cs
- CacheForPrimitiveTypes.cs
- LinqDataSourceContextData.cs
- KnowledgeBase.cs
- Pens.cs
- CustomTrackingQuery.cs
- ProvidersHelper.cs
- RtType.cs
- TextRange.cs
- XmlSchemaSimpleContentRestriction.cs
- Stroke2.cs
- LabelAutomationPeer.cs
- ReadOnlyActivityGlyph.cs
- OutputCacheSection.cs
- HttpBrowserCapabilitiesWrapper.cs
- BaseValidator.cs
- PipelineComponent.cs
- ConstNode.cs
- brushes.cs
- QilStrConcatenator.cs
- Model3DCollection.cs
- BasicBrowserDialog.cs
- OuterGlowBitmapEffect.cs
- XmlAutoDetectWriter.cs
- TableParagraph.cs
- SimpleLine.cs
- FileChangesMonitor.cs
- NetSectionGroup.cs
- XamlContextStack.cs
- ColorConvertedBitmapExtension.cs
- TraceUtility.cs
- OdbcException.cs
- MetadataCollection.cs
- __ConsoleStream.cs
- MemberInitExpression.cs
- TaskFormBase.cs
- MatrixTransform3D.cs
- InvalidPropValue.cs
- DockPattern.cs
- TableLayoutPanelCellPosition.cs
- GenericTypeParameterConverter.cs
- ScrollContentPresenter.cs
- Pair.cs
- QueryableFilterRepeater.cs
- ToolboxBitmapAttribute.cs
- Content.cs
- CssTextWriter.cs
- GlyphingCache.cs
- MenuItemAutomationPeer.cs
- TextDecorationCollection.cs
- MonthCalendar.cs
- ObjectDataSourceChooseMethodsPanel.cs
- AdornedElementPlaceholder.cs
- KeyConverter.cs
- TabItem.cs
- SpellerError.cs
- FixUp.cs
- UpdateRecord.cs
- OracleParameterCollection.cs
- SchemaUtility.cs
- Win32.cs
- MethodBody.cs
- SystemResources.cs
- ImportContext.cs
- CodeAttributeArgumentCollection.cs
- TreeWalker.cs
- PointLightBase.cs
- SmtpMail.cs
- XmlnsDictionary.cs
- SamlSecurityTokenAuthenticator.cs
- _SslState.cs
- ExtendedProtectionPolicyTypeConverter.cs
- ContentOperations.cs
- CustomWebEventKey.cs
- SafeNativeMethods.cs
- HtmlTableCell.cs
- CompiledAction.cs
- ValidatingReaderNodeData.cs
- WebHttpEndpoint.cs
- UpdateTranslator.cs
- XamlReader.cs
- ColorInterpolationModeValidation.cs
- SortedList.cs
- ManagedWndProcTracker.cs
- DriveInfo.cs
- TreeNodeCollection.cs
- XamlValidatingReader.cs
- NonBatchDirectoryCompiler.cs
- SafeFileHandle.cs
- FixUpCollection.cs
- StylusEditingBehavior.cs
- DelayedRegex.cs
- StateManagedCollection.cs
- Socket.cs
- FixedTextPointer.cs
- ScriptResourceInfo.cs
- InnerItemCollectionView.cs
- OdbcParameter.cs
- BamlVersionHeader.cs