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
- SecurityToken.cs
- CompilerErrorCollection.cs
- OdbcParameterCollection.cs
- ServerValidateEventArgs.cs
- Span.cs
- ManagedFilter.cs
- ActivityTypeCodeDomSerializer.cs
- IISMapPath.cs
- DocComment.cs
- XmlWrappingReader.cs
- TextTreeTextElementNode.cs
- HostingEnvironmentSection.cs
- CredentialCache.cs
- IPipelineRuntime.cs
- SqlVersion.cs
- SystemTcpConnection.cs
- DefaultPrintController.cs
- Peer.cs
- coordinatorfactory.cs
- Pool.cs
- EncoderFallback.cs
- XdrBuilder.cs
- ToolStripDropDownMenu.cs
- SecurityElementBase.cs
- SHA256Managed.cs
- AsyncCompletedEventArgs.cs
- DataRecordInternal.cs
- SafeNativeMemoryHandle.cs
- RoleService.cs
- StateMachineHistory.cs
- TypeElementCollection.cs
- TrustSection.cs
- SignatureHelper.cs
- Scripts.cs
- SynchronizedDisposablePool.cs
- Parameter.cs
- TextContainerChangedEventArgs.cs
- MimeTypeAttribute.cs
- StylusButtonEventArgs.cs
- ReliableSessionBindingElement.cs
- XmlSchemaAll.cs
- CheckBoxRenderer.cs
- XmlException.cs
- DataServiceHostFactory.cs
- DirectoryNotFoundException.cs
- SudsCommon.cs
- x509utils.cs
- ClientSettingsProvider.cs
- RawTextInputReport.cs
- AuthenticationConfig.cs
- InputBindingCollection.cs
- Models.cs
- DocumentPageView.cs
- ImageDrawing.cs
- TaiwanLunisolarCalendar.cs
- TrackBar.cs
- TagPrefixAttribute.cs
- ResourceSet.cs
- SynchronizingStream.cs
- TranslateTransform3D.cs
- XmlDocumentFragment.cs
- Substitution.cs
- ColumnClickEvent.cs
- StorageFunctionMapping.cs
- Buffer.cs
- EntityCommand.cs
- FlowPosition.cs
- WindowVisualStateTracker.cs
- SoapException.cs
- TypeSystem.cs
- MappingModelBuildProvider.cs
- Viewport2DVisual3D.cs
- CodeMethodReturnStatement.cs
- HandlerMappingMemo.cs
- BamlRecordWriter.cs
- SerializationException.cs
- DataGridViewBand.cs
- PropertyEntry.cs
- UrlRoutingModule.cs
- versioninfo.cs
- EditorBrowsableAttribute.cs
- BooleanFunctions.cs
- XmlAnyElementAttributes.cs
- parserscommon.cs
- SchemaNames.cs
- Win32SafeHandles.cs
- XmlSerializerVersionAttribute.cs
- sortedlist.cs
- CollectionViewGroup.cs
- ConfigXmlCDataSection.cs
- PropVariant.cs
- SizeChangedEventArgs.cs
- SelectionUIHandler.cs
- XmlSchemaExternal.cs
- FontNameEditor.cs
- ScrollProviderWrapper.cs
- PictureBox.cs
- BuildResultCache.cs
- DataGridViewRowEventArgs.cs
- FrameworkObject.cs