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
- SerializerProvider.cs
- TrailingSpaceComparer.cs
- PngBitmapEncoder.cs
- XmlSchemaValidationException.cs
- TranslateTransform3D.cs
- MessageQueue.cs
- DefaultMemberAttribute.cs
- LassoHelper.cs
- TypeBrowser.xaml.cs
- IPAddress.cs
- ELinqQueryState.cs
- DirectoryNotFoundException.cs
- ConnectionStringSettingsCollection.cs
- FixUpCollection.cs
- HttpModuleAction.cs
- BinaryExpression.cs
- LinkTarget.cs
- CodeStatement.cs
- WebControlsSection.cs
- AsyncMethodInvoker.cs
- EventLogPermissionEntry.cs
- FastEncoder.cs
- HandlerMappingMemo.cs
- KnownTypesHelper.cs
- ImageDrawing.cs
- KeyPullup.cs
- Vector3DKeyFrameCollection.cs
- StyleXamlParser.cs
- PixelShader.cs
- XmlReturnReader.cs
- CodeTypeMember.cs
- DataViewManagerListItemTypeDescriptor.cs
- RoutedEventHandlerInfo.cs
- SqlUDTStorage.cs
- ConfigXmlWhitespace.cs
- ServiceModelActivationSectionGroup.cs
- ComMethodElementCollection.cs
- SoapAttributeAttribute.cs
- DataRowCollection.cs
- DeclarativeCatalogPartDesigner.cs
- TimelineClockCollection.cs
- AlphaSortedEnumConverter.cs
- ValidationPropertyAttribute.cs
- TargetConverter.cs
- IISUnsafeMethods.cs
- ClientTarget.cs
- CachedTypeface.cs
- OneToOneMappingSerializer.cs
- ParseElement.cs
- AutoCompleteStringCollection.cs
- SiteMembershipCondition.cs
- Codec.cs
- EarlyBoundInfo.cs
- CollectionDataContractAttribute.cs
- VBIdentifierTrimConverter.cs
- ProgressBarBrushConverter.cs
- CustomError.cs
- DataGridTextBox.cs
- FunctionNode.cs
- Automation.cs
- TextStore.cs
- TouchPoint.cs
- CachedTypeface.cs
- LabelAutomationPeer.cs
- WCFBuildProvider.cs
- XamlTemplateSerializer.cs
- CacheEntry.cs
- XmlSchemaType.cs
- RelationshipConstraintValidator.cs
- HtmlUtf8RawTextWriter.cs
- ProxyAttribute.cs
- QilValidationVisitor.cs
- HyperlinkAutomationPeer.cs
- EventMappingSettings.cs
- FixedSOMImage.cs
- TextLineResult.cs
- SettingsAttributeDictionary.cs
- Parser.cs
- RuntimeWrappedException.cs
- CommandEventArgs.cs
- WebPartUserCapability.cs
- Dictionary.cs
- CompareValidator.cs
- TextOnlyOutput.cs
- ColorContextHelper.cs
- TextRange.cs
- GlyphingCache.cs
- NotFiniteNumberException.cs
- DependencyObject.cs
- Selection.cs
- CLRBindingWorker.cs
- DiagnosticTrace.cs
- TagPrefixInfo.cs
- ItemContainerPattern.cs
- DeviceOverridableAttribute.cs
- ModelUIElement3D.cs
- SqlStream.cs
- InputProcessorProfilesLoader.cs
- KeyMatchBuilder.cs
- ToolTipAutomationPeer.cs