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
- AssemblyHelper.cs
- PointValueSerializer.cs
- DbDataAdapter.cs
- Configuration.cs
- FormViewInsertedEventArgs.cs
- RecordsAffectedEventArgs.cs
- CheckBoxRenderer.cs
- Tuple.cs
- HttpCapabilitiesSectionHandler.cs
- BrushConverter.cs
- UxThemeWrapper.cs
- ExpandCollapsePattern.cs
- OLEDB_Util.cs
- CustomValidator.cs
- OrderedDictionary.cs
- BindingExpression.cs
- RoutedCommand.cs
- XmlAttributeProperties.cs
- DataGridViewImageColumn.cs
- ResourcesChangeInfo.cs
- ContentElement.cs
- EnumerationRangeValidationUtil.cs
- CommentGlyph.cs
- TableParagraph.cs
- Literal.cs
- ContextMenuStrip.cs
- PathSegmentCollection.cs
- TypeUnloadedException.cs
- StringFreezingAttribute.cs
- HtmlElementErrorEventArgs.cs
- LinqDataSourceView.cs
- ScrollProperties.cs
- HttpProfileGroupBase.cs
- EnterpriseServicesHelper.cs
- StyleModeStack.cs
- SynchronizationLockException.cs
- CodeAccessPermission.cs
- PassportAuthentication.cs
- ShortcutKeysEditor.cs
- PointCollection.cs
- DefaultTraceListener.cs
- SafeBitVector32.cs
- UIPropertyMetadata.cs
- Collection.cs
- ProxyHwnd.cs
- _HelperAsyncResults.cs
- UmAlQuraCalendar.cs
- XsltInput.cs
- LineMetrics.cs
- StringCollection.cs
- EncodingNLS.cs
- BooleanKeyFrameCollection.cs
- Pair.cs
- XmlCompatibilityReader.cs
- wgx_commands.cs
- WebHttpElement.cs
- _AutoWebProxyScriptWrapper.cs
- Debug.cs
- AnnotationDocumentPaginator.cs
- DataTableClearEvent.cs
- StaticDataManager.cs
- EntityRecordInfo.cs
- DBConnectionString.cs
- securestring.cs
- DataGrid.cs
- UnauthorizedAccessException.cs
- TypeExtensionSerializer.cs
- WebControlsSection.cs
- serverconfig.cs
- TextRangeEditTables.cs
- XPathNavigatorReader.cs
- XmlSerializerOperationGenerator.cs
- Internal.cs
- X509Certificate.cs
- DependencyPropertyConverter.cs
- FocusWithinProperty.cs
- UnhandledExceptionEventArgs.cs
- NewArray.cs
- OutKeywords.cs
- MethodImplAttribute.cs
- FixedTextContainer.cs
- EncoderNLS.cs
- DirectoryObjectSecurity.cs
- PointCollection.cs
- SqlConnectionHelper.cs
- SkinBuilder.cs
- HttpApplicationFactory.cs
- TextBoxRenderer.cs
- MetabaseSettings.cs
- BrowserInteropHelper.cs
- RequestQueryProcessor.cs
- OpacityConverter.cs
- BulletedListDesigner.cs
- ClientSettings.cs
- ControllableStoryboardAction.cs
- ProfileSettings.cs
- ComponentGlyph.cs
- UnsafePeerToPeerMethods.cs
- ObjectNavigationPropertyMapping.cs
- CapabilitiesState.cs