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
- StylusPlugin.cs
- WaitForChangedResult.cs
- EventMappingSettings.cs
- NativeMethods.cs
- WebCodeGenerator.cs
- PrintDialog.cs
- StrokeNodeData.cs
- XamlFrame.cs
- ExpressionEvaluator.cs
- XPathNodeInfoAtom.cs
- ConstraintStruct.cs
- Panel.cs
- TextUtf8RawTextWriter.cs
- HtmlGenericControl.cs
- BamlStream.cs
- PersonalizablePropertyEntry.cs
- ColorConvertedBitmap.cs
- QilXmlWriter.cs
- Model3DGroup.cs
- versioninfo.cs
- AssemblySettingAttributes.cs
- SoapAttributes.cs
- ArraySegment.cs
- CodeAccessPermission.cs
- GroupStyle.cs
- PrefixQName.cs
- DefaultWorkflowSchedulerService.cs
- ConstraintEnumerator.cs
- IProducerConsumerCollection.cs
- EdmScalarPropertyAttribute.cs
- TextAutomationPeer.cs
- PageFunction.cs
- LinqToSqlWrapper.cs
- EntityPropertyMappingAttribute.cs
- UnitySerializationHolder.cs
- CrossContextChannel.cs
- MouseButton.cs
- ResXResourceReader.cs
- ContainerUtilities.cs
- SqlUserDefinedAggregateAttribute.cs
- ControlBuilder.cs
- RegularExpressionValidator.cs
- CodeTypeDeclarationCollection.cs
- PlainXmlDeserializer.cs
- BinaryMethodMessage.cs
- NameValueCache.cs
- WebPartRestoreVerb.cs
- SrgsRule.cs
- ResXDataNode.cs
- EdmConstants.cs
- Renderer.cs
- SoapSchemaExporter.cs
- BrushConverter.cs
- TransformGroup.cs
- OpenTypeLayoutCache.cs
- ZoomingMessageFilter.cs
- UseAttributeSetsAction.cs
- GcHandle.cs
- SqlCacheDependencyDatabase.cs
- SchemaObjectWriter.cs
- DataGridItemEventArgs.cs
- Encoding.cs
- CapabilitiesState.cs
- Matrix3DStack.cs
- EncoderParameters.cs
- TileBrush.cs
- Scanner.cs
- FilterUserControlBase.cs
- FaultBookmark.cs
- XPathDocumentNavigator.cs
- SerializationAttributes.cs
- IBuiltInEvidence.cs
- DotExpr.cs
- Calendar.cs
- HtmlToClrEventProxy.cs
- HostProtectionException.cs
- BooleanAnimationUsingKeyFrames.cs
- WsatConfiguration.cs
- cache.cs
- CodeSubDirectory.cs
- WindowsIdentity.cs
- ProcessModule.cs
- CookieParameter.cs
- SqlNotificationEventArgs.cs
- RichTextBoxAutomationPeer.cs
- XomlCompilerHelpers.cs
- EventLogLink.cs
- DataGridViewLayoutData.cs
- Comparer.cs
- AttachmentService.cs
- WindowsStatic.cs
- ProxyGenerator.cs
- ResourcePropertyMemberCodeDomSerializer.cs
- ResourcePart.cs
- AttributeParameterInfo.cs
- HMACSHA512.cs
- RowVisual.cs
- DeviceContexts.cs
- MenuItemBindingCollection.cs
- ChunkedMemoryStream.cs