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
- TextChange.cs
- GridViewDeleteEventArgs.cs
- ToolboxCategory.cs
- DecimalStorage.cs
- DataGridViewBand.cs
- ImageButton.cs
- SafeCertificateStore.cs
- Utilities.cs
- ObsoleteAttribute.cs
- MsmqMessage.cs
- ApplicationServiceHelper.cs
- IndexerNameAttribute.cs
- PeerNameResolver.cs
- SecurityDescriptor.cs
- ExceptionUtil.cs
- IdentityManager.cs
- ClaimTypeRequirement.cs
- CheckBoxPopupAdapter.cs
- CodeObject.cs
- FileDialog.cs
- HtmlUtf8RawTextWriter.cs
- KeyboardNavigation.cs
- ListViewContainer.cs
- DiagnosticsElement.cs
- ListViewItemSelectionChangedEvent.cs
- StorageFunctionMapping.cs
- PingReply.cs
- DbConnectionInternal.cs
- HttpGetProtocolReflector.cs
- WebPartsSection.cs
- ProfileInfo.cs
- XmlUtf8RawTextWriter.cs
- TextElementAutomationPeer.cs
- Int32.cs
- MimeMapping.cs
- ControlDesigner.cs
- DeploymentSection.cs
- CurrencyManager.cs
- VScrollProperties.cs
- DiscreteKeyFrames.cs
- BamlBinaryReader.cs
- ETagAttribute.cs
- RIPEMD160.cs
- WindowClosedEventArgs.cs
- CryptoKeySecurity.cs
- SqlCrossApplyToCrossJoin.cs
- TemplateBindingExpression.cs
- LassoSelectionBehavior.cs
- ReferenceConverter.cs
- NameSpaceExtractor.cs
- FamilyTypefaceCollection.cs
- LineVisual.cs
- CodeFieldReferenceExpression.cs
- HtmlElementEventArgs.cs
- _ProxyChain.cs
- ObjectDataSourceMethodEventArgs.cs
- XmlSchemaObject.cs
- CapabilitiesSection.cs
- XmlSchemaRedefine.cs
- ScrollViewerAutomationPeer.cs
- OutputCacheSection.cs
- PageAsyncTaskManager.cs
- ConsoleEntryPoint.cs
- ThemeDirectoryCompiler.cs
- IBuiltInEvidence.cs
- ProviderUtil.cs
- ExternalFile.cs
- OrderedParallelQuery.cs
- PolicyException.cs
- PointHitTestResult.cs
- OleDbPropertySetGuid.cs
- ListBox.cs
- PageParserFilter.cs
- CodeAccessPermission.cs
- MimeBasePart.cs
- NetworkInterface.cs
- BuildDependencySet.cs
- AutomationIdentifierGuids.cs
- XmlAttributes.cs
- PkcsMisc.cs
- InternalConfigRoot.cs
- ScrollBarRenderer.cs
- ValidationPropertyAttribute.cs
- GeometryCollection.cs
- DBDataPermission.cs
- GifBitmapEncoder.cs
- TypedTableHandler.cs
- UnsafeNativeMethods.cs
- ComponentEditorForm.cs
- BoundField.cs
- ChildrenQuery.cs
- XmlJsonReader.cs
- DataBinding.cs
- MarshalByRefObject.cs
- MaskedTextBox.cs
- AssemblyCollection.cs
- DecodeHelper.cs
- BufferedGraphicsManager.cs
- DBCSCodePageEncoding.cs
- CultureSpecificStringDictionary.cs