Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / tx / System / Transactions / SafeIUnknown.cs / 1305376 / SafeIUnknown.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Transactions { using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.ConstrainedExecution; using System.Security.Permissions; // Keep an interface pointer that will not be used in a SafeHandle derived so // that it will be properly released. internal sealed class SafeIUnknown : SafeHandle { // This constructor is called by ComInterop [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal SafeIUnknown() : base(IntPtr.Zero, true) { } // This constructor is called by ComInterop [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal SafeIUnknown(IntPtr unknown) : base(IntPtr.Zero, true) { RuntimeHelpers.PrepareConstrainedRegions(); try {} finally { base.handle = unknown; } } public override bool IsInvalid { get { return (IsClosed || (IntPtr.Zero == base.handle)); } } override protected bool ReleaseHandle() { // NOTE: The SafeHandle class guarantees this will be called exactly once. IntPtr ptr = base.handle; base.handle = IntPtr.Zero; if (IntPtr.Zero != ptr) { Marshal.Release(ptr); } return true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Transactions { using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.ConstrainedExecution; using System.Security.Permissions; // Keep an interface pointer that will not be used in a SafeHandle derived so // that it will be properly released. internal sealed class SafeIUnknown : SafeHandle { // This constructor is called by ComInterop [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal SafeIUnknown() : base(IntPtr.Zero, true) { } // This constructor is called by ComInterop [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal SafeIUnknown(IntPtr unknown) : base(IntPtr.Zero, true) { RuntimeHelpers.PrepareConstrainedRegions(); try {} finally { base.handle = unknown; } } public override bool IsInvalid { get { return (IsClosed || (IntPtr.Zero == base.handle)); } } override protected bool ReleaseHandle() { // NOTE: The SafeHandle class guarantees this will be called exactly once. IntPtr ptr = base.handle; base.handle = IntPtr.Zero; if (IntPtr.Zero != ptr) { Marshal.Release(ptr); } return true; } } } // 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
- DataChangedEventManager.cs
- CodeAssignStatement.cs
- TextSchema.cs
- VectorCollectionValueSerializer.cs
- ExpressionVisitor.cs
- MouseButtonEventArgs.cs
- TypeDefinition.cs
- _NativeSSPI.cs
- HitTestFilterBehavior.cs
- ChtmlTextWriter.cs
- Rect3DValueSerializer.cs
- CryptoApi.cs
- ApplicationHost.cs
- BuildProviderAppliesToAttribute.cs
- DocumentViewerBase.cs
- Trace.cs
- InputQueue.cs
- NativeObjectSecurity.cs
- AutoGeneratedFieldProperties.cs
- Pen.cs
- NumericUpDownAcceleration.cs
- ReachSerializationUtils.cs
- ServicePoint.cs
- TextAction.cs
- TrustManager.cs
- BasicHttpBindingCollectionElement.cs
- TabControlEvent.cs
- FormDesigner.cs
- MenuTracker.cs
- XmlSchemaImport.cs
- XPathDocumentIterator.cs
- StyleModeStack.cs
- TraceProvider.cs
- Transform.cs
- Win32MouseDevice.cs
- QuotedPrintableStream.cs
- DeviceSpecific.cs
- XmlDocument.cs
- ViewgenContext.cs
- Pen.cs
- ExpressionSelection.cs
- MbpInfo.cs
- _OverlappedAsyncResult.cs
- CodeMemberEvent.cs
- PagesSection.cs
- WbmpConverter.cs
- EventSetter.cs
- WebControlParameterProxy.cs
- Permission.cs
- RegistryPermission.cs
- Point.cs
- WebBaseEventKeyComparer.cs
- DecimalAnimationBase.cs
- NotCondition.cs
- DbXmlEnabledProviderManifest.cs
- Message.cs
- CustomValidator.cs
- GC.cs
- mda.cs
- XmlSerializationGeneratedCode.cs
- AssemblyHelper.cs
- QilSortKey.cs
- GridViewUpdateEventArgs.cs
- LinkTarget.cs
- HttpCapabilitiesSectionHandler.cs
- FormsAuthenticationConfiguration.cs
- Logging.cs
- ToolStripCollectionEditor.cs
- RegisteredArrayDeclaration.cs
- QueryGenerator.cs
- InputProcessorProfiles.cs
- TableLayoutRowStyleCollection.cs
- BitArray.cs
- ScrollBarRenderer.cs
- Speller.cs
- DetectRunnableInstancesTask.cs
- QuadraticBezierSegment.cs
- BooleanProjectedSlot.cs
- PrintEvent.cs
- wmiutil.cs
- FontCacheLogic.cs
- RegexWriter.cs
- XmlWrappingReader.cs
- QilCloneVisitor.cs
- EntityDataSourceEntitySetNameItem.cs
- LinqDataSourceHelper.cs
- GACIdentityPermission.cs
- StylusPointPropertyId.cs
- DesignSurfaceServiceContainer.cs
- Native.cs
- ToolStripGrip.cs
- PersonalizableTypeEntry.cs
- ItemCollection.cs
- FlagsAttribute.cs
- XPathDescendantIterator.cs
- BCLDebug.cs
- EventLogConfiguration.cs
- SecurityKeyType.cs
- sqlinternaltransaction.cs
- MultiPropertyDescriptorGridEntry.cs