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
- BasicKeyConstraint.cs
- OutOfMemoryException.cs
- PagesSection.cs
- ManagedWndProcTracker.cs
- IntegerValidator.cs
- MailFileEditor.cs
- BackStopAuthenticationModule.cs
- WorkflowInlining.cs
- UnmanagedMarshal.cs
- Win32KeyboardDevice.cs
- PrintController.cs
- DebugTraceHelper.cs
- Version.cs
- Stream.cs
- BitmapVisualManager.cs
- Int32Animation.cs
- HelpProvider.cs
- RijndaelManaged.cs
- DataPager.cs
- BitmapCache.cs
- ZipArchive.cs
- SafeThemeHandle.cs
- ComponentEvent.cs
- CodeAttributeDeclaration.cs
- MultipleViewProviderWrapper.cs
- XmlSerializableReader.cs
- MembershipPasswordException.cs
- DocumentPageViewAutomationPeer.cs
- TextBreakpoint.cs
- AddInIpcChannel.cs
- DesignerTransaction.cs
- _NetworkingPerfCounters.cs
- StartUpEventArgs.cs
- UnsafeNativeMethods.cs
- MatcherBuilder.cs
- FamilyMap.cs
- TableCell.cs
- formatter.cs
- CodeNamespaceImport.cs
- XPathScanner.cs
- XmlSchemaSimpleTypeRestriction.cs
- PixelFormat.cs
- Condition.cs
- Range.cs
- SelectorAutomationPeer.cs
- SerialReceived.cs
- ConnectionStringsSection.cs
- TraceHandlerErrorFormatter.cs
- LockCookie.cs
- NameTable.cs
- SpeechRecognizer.cs
- ConfigurationStrings.cs
- ImmComposition.cs
- StylusPoint.cs
- PersonalizationProviderHelper.cs
- _NegoState.cs
- Parsers.cs
- TextSelectionProcessor.cs
- BezierSegment.cs
- RegistryHandle.cs
- ConfigXmlDocument.cs
- DbgCompiler.cs
- KeyValuePairs.cs
- XpsManager.cs
- StringValidator.cs
- BitmapCacheBrush.cs
- Size3DValueSerializer.cs
- NullableIntSumAggregationOperator.cs
- FileAuthorizationModule.cs
- DataBinder.cs
- CompletedAsyncResult.cs
- Tile.cs
- HtmlElementEventArgs.cs
- NullableFloatSumAggregationOperator.cs
- SamlAssertion.cs
- KnownBoxes.cs
- MetadataSerializer.cs
- DropDownButton.cs
- NativeMethods.cs
- BitmapInitialize.cs
- FunctionImportElement.cs
- BroadcastEventHelper.cs
- SerializationAttributes.cs
- PrimitiveDataContract.cs
- SoapFault.cs
- Brush.cs
- initElementDictionary.cs
- WebErrorHandler.cs
- InputLanguageCollection.cs
- RightsManagementEncryptedStream.cs
- DataGridRelationshipRow.cs
- MaskPropertyEditor.cs
- ScriptingWebServicesSectionGroup.cs
- InstanceNotReadyException.cs
- Environment.cs
- HiddenField.cs
- Authorization.cs
- _SingleItemRequestCache.cs
- PersianCalendar.cs
- XmlWhitespace.cs