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
- MimeWriter.cs
- _HeaderInfoTable.cs
- RepeaterItemCollection.cs
- EntityModelBuildProvider.cs
- PartitionedStreamMerger.cs
- DynamicValidatorEventArgs.cs
- AsyncOperationContext.cs
- GatewayDefinition.cs
- ContentControl.cs
- RulePatternOps.cs
- PerformanceCounterPermissionAttribute.cs
- String.cs
- XhtmlMobileTextWriter.cs
- ExpressionVisitor.cs
- TreeViewImageIndexConverter.cs
- Highlights.cs
- XmlSchemaCollection.cs
- WebConfigurationHostFileChange.cs
- BufferBuilder.cs
- DataTableNewRowEvent.cs
- ControlAdapter.cs
- CompilerError.cs
- PaperSize.cs
- ObjectManager.cs
- ReachDocumentSequenceSerializerAsync.cs
- GraphicsContext.cs
- CheckBoxList.cs
- TargetParameterCountException.cs
- X509Certificate2Collection.cs
- Vector3dCollection.cs
- AdornerHitTestResult.cs
- RemoteWebConfigurationHost.cs
- ByeMessageApril2005.cs
- PrintDocument.cs
- HitTestParameters.cs
- BufferedGraphics.cs
- EmptyCollection.cs
- DataService.cs
- TemplateControlBuildProvider.cs
- TextPenaltyModule.cs
- UInt32Converter.cs
- XmlHierarchyData.cs
- unsafenativemethodsother.cs
- BroadcastEventHelper.cs
- SoapCodeExporter.cs
- HttpConfigurationContext.cs
- IntSecurity.cs
- EventManager.cs
- EtwTrackingParticipant.cs
- XmlObjectSerializerReadContextComplexJson.cs
- CodeAttributeDeclaration.cs
- SqlConnectionHelper.cs
- Converter.cs
- sortedlist.cs
- OleCmdHelper.cs
- GenericXmlSecurityToken.cs
- SafePointer.cs
- PathGeometry.cs
- ToolStripPanelRow.cs
- XPathSelfQuery.cs
- XsdCachingReader.cs
- ProfessionalColors.cs
- SkipStoryboardToFill.cs
- CodeTypeReference.cs
- DataControlImageButton.cs
- TreeNodeCollection.cs
- StoreAnnotationsMap.cs
- MailAddress.cs
- infer.cs
- input.cs
- AnimationException.cs
- KeyToListMap.cs
- WindowsSysHeader.cs
- HashMembershipCondition.cs
- HierarchicalDataBoundControl.cs
- SurrogateEncoder.cs
- EndOfStreamException.cs
- XmlUtil.cs
- Closure.cs
- Sql8ExpressionRewriter.cs
- EditorPartCollection.cs
- CustomAttributeSerializer.cs
- WrappedDispatcherException.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- CacheMemory.cs
- IsolatedStorage.cs
- QuotedPrintableStream.cs
- Utils.cs
- DoubleCollection.cs
- BoundColumn.cs
- SaveRecipientRequest.cs
- Domain.cs
- PresentationSource.cs
- ErrorRuntimeConfig.cs
- ScalarConstant.cs
- DataServiceHost.cs
- Mouse.cs
- DesignerValidatorAdapter.cs
- BitmapEffectGroup.cs
- ServiceBusyException.cs