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
- _AcceptOverlappedAsyncResult.cs
- TabletCollection.cs
- XpsFilter.cs
- PictureBox.cs
- CodeBlockBuilder.cs
- SystemDiagnosticsSection.cs
- FileLogRecordStream.cs
- TimestampInformation.cs
- DataBindingHandlerAttribute.cs
- CfgParser.cs
- ConstraintStruct.cs
- UnmanagedMemoryStream.cs
- CompareValidator.cs
- DbProviderServices.cs
- Attributes.cs
- IntSecurity.cs
- PropertyEmitterBase.cs
- Guid.cs
- Matrix3DStack.cs
- WindowsListBox.cs
- ServiceParser.cs
- Win32SafeHandles.cs
- DataSysAttribute.cs
- FormViewPagerRow.cs
- CodeObject.cs
- LinqToSqlWrapper.cs
- GridViewCellAutomationPeer.cs
- SettingsContext.cs
- EndpointBehaviorElementCollection.cs
- PerformanceCountersElement.cs
- _ProxyChain.cs
- ScrollEventArgs.cs
- ListChangedEventArgs.cs
- NgenServicingAttributes.cs
- ToolStripContainer.cs
- PtsContext.cs
- Currency.cs
- DiscoveryClientReferences.cs
- SecurityPolicySection.cs
- UnsupportedPolicyOptionsException.cs
- WindowsListView.cs
- ObfuscateAssemblyAttribute.cs
- PresentationTraceSources.cs
- KnownTypes.cs
- InheritanceAttribute.cs
- SHA512Managed.cs
- NativeCompoundFileAPIs.cs
- CollectionMarkupSerializer.cs
- SpnegoTokenAuthenticator.cs
- ReflectionUtil.cs
- RuleRefElement.cs
- Classification.cs
- XsltLibrary.cs
- Misc.cs
- IDReferencePropertyAttribute.cs
- NavigationExpr.cs
- ComponentChangingEvent.cs
- WSSecurityOneDotOneSendSecurityHeader.cs
- SqlDelegatedTransaction.cs
- TransformationRules.cs
- TextServicesManager.cs
- translator.cs
- EventWaitHandle.cs
- StorageAssociationTypeMapping.cs
- MatrixValueSerializer.cs
- EntityDataSourceValidationException.cs
- WmpBitmapEncoder.cs
- DeclarativeConditionsCollection.cs
- Compiler.cs
- DateTimeFormatInfo.cs
- ClientScriptManagerWrapper.cs
- GridErrorDlg.cs
- CodeLinePragma.cs
- TextAction.cs
- SapiRecoInterop.cs
- UpdateManifestForBrowserApplication.cs
- ControllableStoryboardAction.cs
- XmlExpressionDumper.cs
- VSWCFServiceContractGenerator.cs
- assertwrapper.cs
- WebPartZoneCollection.cs
- XamlInt32CollectionSerializer.cs
- CrossContextChannel.cs
- Types.cs
- BitmapCodecInfoInternal.cs
- RegexGroup.cs
- WebBrowserBase.cs
- FileFormatException.cs
- HttpWebRequest.cs
- InputQueue.cs
- pingexception.cs
- MsmqMessage.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- CodeGroup.cs
- CryptoStream.cs
- OletxDependentTransaction.cs
- TabPage.cs
- StylusEventArgs.cs
- ContextBase.cs
- DataServiceContext.cs