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
- Vector3DCollectionValueSerializer.cs
- PageBreakRecord.cs
- CompilerScopeManager.cs
- PopupRoot.cs
- SlipBehavior.cs
- CompilationPass2TaskInternal.cs
- bidPrivateBase.cs
- UrlPropertyAttribute.cs
- DependencyPropertyAttribute.cs
- CancellationState.cs
- TreeViewItem.cs
- MetaColumn.cs
- ScrollableControl.cs
- TraceHandlerErrorFormatter.cs
- GridViewSortEventArgs.cs
- ListViewTableRow.cs
- MemberHolder.cs
- ParserExtension.cs
- DesignerDeviceConfig.cs
- MetadataSource.cs
- HostedBindingBehavior.cs
- PerformanceCounterManager.cs
- HttpAsyncResult.cs
- Semaphore.cs
- RNGCryptoServiceProvider.cs
- SectionVisual.cs
- SqlClientMetaDataCollectionNames.cs
- SafeFreeMibTable.cs
- GuidelineCollection.cs
- PropertyToken.cs
- CommandBinding.cs
- PagesSection.cs
- TreeViewCancelEvent.cs
- ExpressionBindingsDialog.cs
- BamlMapTable.cs
- WpfWebRequestHelper.cs
- HtmlImage.cs
- DefaultAssemblyResolver.cs
- Exceptions.cs
- XamlTreeBuilder.cs
- Int16Animation.cs
- SystemTcpConnection.cs
- AmbientLight.cs
- FormatterServices.cs
- ScriptMethodAttribute.cs
- RijndaelManaged.cs
- PenThreadWorker.cs
- Publisher.cs
- ArithmeticLiteral.cs
- PkcsMisc.cs
- VersionUtil.cs
- FieldMetadata.cs
- XmlSchemaObject.cs
- InvalidAsynchronousStateException.cs
- nulltextnavigator.cs
- UIPropertyMetadata.cs
- EmbeddedMailObjectsCollection.cs
- MapPathBasedVirtualPathProvider.cs
- UnsafeNativeMethods.cs
- ArithmeticLiteral.cs
- ClrPerspective.cs
- TypedTableGenerator.cs
- xmlfixedPageInfo.cs
- Clock.cs
- SettingsBase.cs
- EncodingDataItem.cs
- XmlDictionaryReaderQuotas.cs
- UseLicense.cs
- ValidatorCollection.cs
- StringDictionary.cs
- CapabilitiesPattern.cs
- DisplayMemberTemplateSelector.cs
- XmlAttributeCollection.cs
- CodeDirectoryCompiler.cs
- BooleanKeyFrameCollection.cs
- Table.cs
- DecimalConstantAttribute.cs
- BadImageFormatException.cs
- ComponentManagerBroker.cs
- RepeaterItemCollection.cs
- SoapAttributeOverrides.cs
- UnsignedPublishLicense.cs
- ReaderWriterLock.cs
- _AutoWebProxyScriptEngine.cs
- RawStylusInputReport.cs
- EmptyElement.cs
- Header.cs
- XPathMultyIterator.cs
- SerializerWriterEventHandlers.cs
- HiddenFieldPageStatePersister.cs
- XmlNodeList.cs
- DataGridViewTextBoxColumn.cs
- XmlSerializerFaultFormatter.cs
- CompilationSection.cs
- DecimalAnimationBase.cs
- Number.cs
- RelativeSource.cs
- ObjectStorage.cs
- AsnEncodedData.cs
- isolationinterop.cs