Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Services / Messaging / System / Messaging / Interop / SafeHandles.cs / 1305376 / SafeHandles.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Messaging.Interop { using System; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; internal class MessageQueueHandle : SafeHandleZeroOrMinusOneIsInvalid { public static readonly MessageQueueHandle InvalidHandle = new InvalidMessageQueueHandle(); MessageQueueHandle() : base(true) {} protected override bool ReleaseHandle() { SafeNativeMethods.MQCloseQueue(this.handle); return true; } public override bool IsInvalid { get { return base.IsInvalid || IsClosed; } } // A subclass needed to express InvalidHandle. The reason is that CLR notices that // ReleaseHandle requires a call to MQRT.DLL, and throws in the ctor if MQRT.DLL is not available, // even though CTOR ITSELF DOES NOT REQUIRE MQRT.DLL. // We address this by defining a NOOP ReleaseHandle sealed class InvalidMessageQueueHandle : MessageQueueHandle { protected override bool ReleaseHandle() { return true; } } } internal class CursorHandle : SafeHandleZeroOrMinusOneIsInvalid { public static readonly CursorHandle NullHandle = new InvalidCursorHandle(); protected CursorHandle() : base(true) {} protected override bool ReleaseHandle() { SafeNativeMethods.MQCloseCursor(this.handle); return true; } public override bool IsInvalid { get { return base.IsInvalid || IsClosed; } } // A subclass needed to express InvalidHandle. The reason is that CLR notices that // ReleaseHandle requires a call to MQRT.DLL, and throws in the ctor if MQRT.DLL is not available, // even though CTOR ITSELF DOES NOT REQUIRE MQRT.DLL. // We address this by defining a NOOP ReleaseHandle sealed class InvalidCursorHandle : CursorHandle { protected override bool ReleaseHandle() { return true; } } } internal class LocatorHandle : SafeHandleZeroOrMinusOneIsInvalid { public static readonly LocatorHandle InvalidHandle = new InvalidLocatorHandle(); protected LocatorHandle() : base(true) {} protected override bool ReleaseHandle() { SafeNativeMethods.MQLocateEnd(this.handle); return true; } public override bool IsInvalid { get { return base.IsInvalid || IsClosed; } } // A subclass needed to express InvalidHandle. The reason is that CLR notices that // ReleaseHandle requires a call to MQRT.DLL, and throws in the ctor if MQRT.DLL is not available, // even though CTOR ITSELF DOES NOT REQUIRE MQRT.DLL. // We address this by defining a NOOP ReleaseHandle sealed class InvalidLocatorHandle : LocatorHandle { protected override bool ReleaseHandle() { return true; } } } internal sealed class SecurityContextHandle : SafeHandleZeroOrMinusOneIsInvalid { internal SecurityContextHandle(IntPtr existingHandle) : base(true) { SetHandle(existingHandle); } protected override bool ReleaseHandle() { SafeNativeMethods.MQFreeSecurityContext(this.handle); return true; } public override bool IsInvalid { get { return base.IsInvalid || IsClosed; } } } } // 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
- SqlFileStream.cs
- MenuScrollingVisibilityConverter.cs
- PersonalizationAdministration.cs
- Point4D.cs
- Margins.cs
- IDispatchConstantAttribute.cs
- WindowsButton.cs
- BuildResult.cs
- SoapSchemaExporter.cs
- AdornerDecorator.cs
- RootBuilder.cs
- DBSchemaTable.cs
- BindingEditor.xaml.cs
- SymmetricAlgorithm.cs
- RoleManagerEventArgs.cs
- Visitor.cs
- DbParameterCollection.cs
- DataGridPreparingCellForEditEventArgs.cs
- Selection.cs
- DoubleAnimationUsingPath.cs
- ActiveXHelper.cs
- DataGridViewImageColumn.cs
- XmlElementList.cs
- OrderedDictionary.cs
- ToolStripMenuItem.cs
- ClientSponsor.cs
- SemaphoreSecurity.cs
- PointKeyFrameCollection.cs
- ProcessStartInfo.cs
- MarkupCompiler.cs
- MutexSecurity.cs
- SystemShuttingDownException.cs
- OneWayBindingElementImporter.cs
- HtmlHead.cs
- MissingMemberException.cs
- IsolatedStorageFilePermission.cs
- HierarchicalDataSourceControl.cs
- BackStopAuthenticationModule.cs
- KeyValueSerializer.cs
- TextModifier.cs
- PartialTrustVisibleAssemblyCollection.cs
- TableItemPatternIdentifiers.cs
- FactoryGenerator.cs
- WebMessageEncodingElement.cs
- UInt64Converter.cs
- CodeIndexerExpression.cs
- WinFormsSpinner.cs
- WebPartHeaderCloseVerb.cs
- Dynamic.cs
- MSG.cs
- FormViewCommandEventArgs.cs
- ProxyWebPart.cs
- MethodExpr.cs
- ListSortDescriptionCollection.cs
- AppDomainProtocolHandler.cs
- TextSelectionHelper.cs
- DecoderNLS.cs
- Query.cs
- FloaterBaseParagraph.cs
- CompilationSection.cs
- JoinElimination.cs
- WeakReferenceList.cs
- RuntimeCompatibilityAttribute.cs
- PartitionedStreamMerger.cs
- IgnoreFlushAndCloseStream.cs
- ExpressionPrefixAttribute.cs
- SHA512.cs
- ListViewInsertionMark.cs
- BinaryObjectWriter.cs
- NameTable.cs
- TranslateTransform.cs
- CurrentTimeZone.cs
- StateManager.cs
- SQLDateTimeStorage.cs
- AsyncCodeActivity.cs
- BeginEvent.cs
- input.cs
- SafeNativeMethods.cs
- SqlServer2KCompatibilityAnnotation.cs
- ReceiveSecurityHeaderElementManager.cs
- MachineKeySection.cs
- ContextDataSourceContextData.cs
- URLAttribute.cs
- UnsafeNativeMethods.cs
- MatrixIndependentAnimationStorage.cs
- EntityViewGenerator.cs
- recordstatefactory.cs
- SerializationInfo.cs
- SplitContainer.cs
- Convert.cs
- FontInfo.cs
- DocumentPageViewAutomationPeer.cs
- RegexTree.cs
- StylusPointPropertyInfo.cs
- FrameworkObject.cs
- WebPermission.cs
- Quaternion.cs
- DebugInfoGenerator.cs
- CapabilitiesAssignment.cs
- StringFreezingAttribute.cs