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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TransactionWaitAsyncResult.cs
- Pen.cs
- SessionEndedEventArgs.cs
- ArrangedElement.cs
- UriTemplatePathSegment.cs
- ExpressionBuilderCollection.cs
- CodeCommentStatement.cs
- DisplayInformation.cs
- ExpressionLexer.cs
- ConstantCheck.cs
- ValidationEventArgs.cs
- DeviceSpecificDialogCachedState.cs
- ScrollViewer.cs
- HttpRuntimeSection.cs
- SrgsDocument.cs
- Pair.cs
- SignalGate.cs
- DataProtectionSecurityStateEncoder.cs
- WhereQueryOperator.cs
- ToolStripDropDownMenu.cs
- XmlNamespaceDeclarationsAttribute.cs
- DrawingAttributesDefaultValueFactory.cs
- NonParentingControl.cs
- BuilderPropertyEntry.cs
- EntityDataSourceMemberPath.cs
- RelationshipSet.cs
- WebHostScriptMappingsInstallComponent.cs
- FrameworkElement.cs
- FunctionMappingTranslator.cs
- StubHelpers.cs
- FullTrustAssemblyCollection.cs
- unsafenativemethodsother.cs
- ImageMapEventArgs.cs
- HttpRuntimeSection.cs
- RepeatButtonAutomationPeer.cs
- FixedTextSelectionProcessor.cs
- KnowledgeBase.cs
- Command.cs
- HtmlProps.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- LinkButton.cs
- SafeRightsManagementSessionHandle.cs
- GridSplitter.cs
- LocalValueEnumerator.cs
- altserialization.cs
- FloatUtil.cs
- TreeNodeStyleCollection.cs
- SByteConverter.cs
- MetadataPropertyAttribute.cs
- Point3DAnimationBase.cs
- TraceEventCache.cs
- TypeExtensions.cs
- Bezier.cs
- TreeNodeBinding.cs
- BinarySerializer.cs
- Module.cs
- HitTestFilterBehavior.cs
- TemplateControl.cs
- PartitionedStream.cs
- HotCommands.cs
- FileUtil.cs
- NullableLongAverageAggregationOperator.cs
- TypeUsageBuilder.cs
- ScrollViewer.cs
- SafeFileMappingHandle.cs
- UInt64Converter.cs
- TeredoHelper.cs
- LogicalExpressionTypeConverter.cs
- VisualTreeHelper.cs
- Stylesheet.cs
- TreeBuilderXamlTranslator.cs
- Attributes.cs
- SqlDataSourceConfigureSortForm.cs
- GridItemPatternIdentifiers.cs
- CommonProperties.cs
- TdsParserStaticMethods.cs
- RelationshipConstraintValidator.cs
- VisualTarget.cs
- HtmlImage.cs
- RoleServiceManager.cs
- Events.cs
- SqlConnection.cs
- DictionaryItemsCollection.cs
- LogSwitch.cs
- SelectionList.cs
- FunctionDescription.cs
- DataTemplate.cs
- RepeaterItemEventArgs.cs
- WindowsFormsLinkLabel.cs
- ObservableCollection.cs
- SparseMemoryStream.cs
- RIPEMD160.cs
- wgx_exports.cs
- OrderedEnumerableRowCollection.cs
- versioninfo.cs
- CrossSiteScriptingValidation.cs
- DefaultIfEmptyQueryOperator.cs
- XmlMessageFormatter.cs
- Point3DKeyFrameCollection.cs
- BitStack.cs