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
- WSDualHttpSecurityMode.cs
- storepermission.cs
- BlockCollection.cs
- SessionSwitchEventArgs.cs
- messageonlyhwndwrapper.cs
- ProjectionPathSegment.cs
- ApplicationException.cs
- EventLogPermissionAttribute.cs
- InkCanvasAutomationPeer.cs
- ResourceKey.cs
- EmissiveMaterial.cs
- WebPartsSection.cs
- GroupItemAutomationPeer.cs
- MsmqOutputChannel.cs
- WaitHandleCannotBeOpenedException.cs
- FixUp.cs
- ActivationArguments.cs
- SocketManager.cs
- XhtmlStyleClass.cs
- Inline.cs
- SecureEnvironment.cs
- Soap11ServerProtocol.cs
- SizeChangedEventArgs.cs
- InstanceContextMode.cs
- Viewport3DVisual.cs
- BridgeDataRecord.cs
- Vector3DKeyFrameCollection.cs
- TextTreeText.cs
- SoapIncludeAttribute.cs
- ListViewItem.cs
- DataRecordInfo.cs
- RequestCachePolicy.cs
- IntegerValidator.cs
- Command.cs
- Rotation3D.cs
- SmiRequestExecutor.cs
- CharacterBufferReference.cs
- ToolBarButtonClickEvent.cs
- ToolboxControl.cs
- RubberbandSelector.cs
- WeakReferenceKey.cs
- NamespaceDecl.cs
- RuleInfoComparer.cs
- ISAPIRuntime.cs
- APCustomTypeDescriptor.cs
- InputMethod.cs
- EnumMember.cs
- PageMediaSize.cs
- GuidelineCollection.cs
- oledbmetadatacolumnnames.cs
- ProxySimple.cs
- MultiAsyncResult.cs
- KeyGestureValueSerializer.cs
- MediaElementAutomationPeer.cs
- HiddenField.cs
- Quaternion.cs
- PageCatalogPart.cs
- EventMap.cs
- Serializer.cs
- MetadataCache.cs
- XamlTemplateSerializer.cs
- GridItemPattern.cs
- MembershipUser.cs
- QueuedDeliveryRequirementsMode.cs
- XamlTypeMapper.cs
- BinaryObjectWriter.cs
- ExpandCollapseIsCheckedConverter.cs
- VBIdentifierTrimConverter.cs
- OuterGlowBitmapEffect.cs
- OutputCacheModule.cs
- PageContentAsyncResult.cs
- FillErrorEventArgs.cs
- OletxTransactionFormatter.cs
- AccessorTable.cs
- StatusBarAutomationPeer.cs
- StringDictionaryEditor.cs
- XmlValidatingReader.cs
- PanelDesigner.cs
- TreeWalkHelper.cs
- FrameworkElementFactoryMarkupObject.cs
- MbpInfo.cs
- OdbcConnection.cs
- ConfigurationSectionCollection.cs
- SqlUdtInfo.cs
- OracleSqlParser.cs
- FileDialogPermission.cs
- NameValueConfigurationCollection.cs
- OdbcCommandBuilder.cs
- GraphicsContainer.cs
- StrongNameIdentityPermission.cs
- PLINQETWProvider.cs
- CryptoProvider.cs
- ReachFixedPageSerializerAsync.cs
- ObfuscationAttribute.cs
- TableCellCollection.cs
- WebException.cs
- Calendar.cs
- AuthenticationModuleElement.cs
- BufferedGraphicsManager.cs
- MaskedTextProvider.cs