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
- ConditionalAttribute.cs
- RequestQueryParser.cs
- PropertyValidationContext.cs
- DocumentXPathNavigator.cs
- XmlSchemaAnyAttribute.cs
- ISO2022Encoding.cs
- QuaternionRotation3D.cs
- HashRepartitionEnumerator.cs
- DomainUpDown.cs
- SID.cs
- ToolStripItemGlyph.cs
- TypedColumnHandler.cs
- WorkflowItemsPresenter.cs
- EventLog.cs
- HTTPNotFoundHandler.cs
- Repeater.cs
- ActivationService.cs
- WebPart.cs
- PeerInvitationResponse.cs
- Sentence.cs
- GenericTypeParameterConverter.cs
- SuppressMergeCheckAttribute.cs
- X509Certificate2Collection.cs
- StrongNameMembershipCondition.cs
- SchemaNotation.cs
- TextBoxBase.cs
- ChannelTerminatedException.cs
- EventMappingSettings.cs
- ManagementScope.cs
- Compilation.cs
- HtmlWindowCollection.cs
- SpecularMaterial.cs
- WebReferencesBuildProvider.cs
- BStrWrapper.cs
- WsdlExporter.cs
- MessageQueueAccessControlEntry.cs
- ProjectionPlan.cs
- TextTreeRootTextBlock.cs
- Models.cs
- EntityConnection.cs
- Substitution.cs
- Transform.cs
- StateItem.cs
- DataGridView.cs
- EventWaitHandleSecurity.cs
- ClientApiGenerator.cs
- DataGridTablesFactory.cs
- ClientSettingsStore.cs
- CodeConditionStatement.cs
- GeneratedContractType.cs
- NonPrimarySelectionGlyph.cs
- SQLCharsStorage.cs
- Transactions.cs
- PermissionSetEnumerator.cs
- RSACryptoServiceProvider.cs
- Command.cs
- FrameworkTextComposition.cs
- TreeViewImageIndexConverter.cs
- WindowsContainer.cs
- LocalTransaction.cs
- SqlDataSourceFilteringEventArgs.cs
- SynchronizationContext.cs
- XmlImplementation.cs
- ClientApiGenerator.cs
- CuspData.cs
- FragmentQueryProcessor.cs
- SettingsPropertyValueCollection.cs
- SizeAnimation.cs
- X509Utils.cs
- RoutingExtensionElement.cs
- WeakReferenceList.cs
- TabletDeviceInfo.cs
- ResourceDisplayNameAttribute.cs
- PermissionSet.cs
- SchemaEntity.cs
- unsafenativemethodsother.cs
- _UncName.cs
- CommonDialog.cs
- DocumentsTrace.cs
- CookieHandler.cs
- FixedLineResult.cs
- ConfigErrorGlyph.cs
- TextRenderingModeValidation.cs
- XmlAttributeAttribute.cs
- DateTimeStorage.cs
- unitconverter.cs
- WebPartTransformerAttribute.cs
- Axis.cs
- PageSetupDialog.cs
- DragDrop.cs
- SoapAttributes.cs
- RectangleGeometry.cs
- PrePostDescendentsWalker.cs
- TreeNodeConverter.cs
- Matrix.cs
- OrderByBuilder.cs
- MouseButton.cs
- GiveFeedbackEventArgs.cs
- TableCell.cs
- EnumerableRowCollection.cs