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
- PageRequestManager.cs
- TableFieldsEditor.cs
- DataControlFieldCollection.cs
- ColumnWidthChangingEvent.cs
- xmlformatgeneratorstatics.cs
- PasswordBoxAutomationPeer.cs
- ManagedIStream.cs
- UserPersonalizationStateInfo.cs
- BinHexDecoder.cs
- storepermissionattribute.cs
- ParagraphVisual.cs
- MSAAWinEventWrap.cs
- RelatedPropertyManager.cs
- GraphicsState.cs
- XmlTypeAttribute.cs
- XmlReader.cs
- WebBrowserNavigatedEventHandler.cs
- WebControlsSection.cs
- ClrPerspective.cs
- RectangleGeometry.cs
- LinqTreeNodeEvaluator.cs
- ParseChildrenAsPropertiesAttribute.cs
- EncoderBestFitFallback.cs
- XmlArrayItemAttributes.cs
- ContentPathSegment.cs
- HttpClientCertificate.cs
- listitem.cs
- DataSetSchema.cs
- ProgressBar.cs
- BooleanAnimationBase.cs
- XmlFormatReaderGenerator.cs
- RuntimeIdentifierPropertyAttribute.cs
- SweepDirectionValidation.cs
- XsltException.cs
- ListViewTableCell.cs
- SecurityAttributeGenerationHelper.cs
- SqlConnectionHelper.cs
- CheckBoxBaseAdapter.cs
- ColorPalette.cs
- Int16AnimationUsingKeyFrames.cs
- CfgArc.cs
- EventListener.cs
- Error.cs
- ValueChangedEventManager.cs
- ArrayListCollectionBase.cs
- RoutedEventArgs.cs
- InitializingNewItemEventArgs.cs
- ArraySortHelper.cs
- ZipIOCentralDirectoryFileHeader.cs
- DeriveBytes.cs
- ProfilePropertySettings.cs
- OwnerDrawPropertyBag.cs
- StringSource.cs
- WindowsIdentity.cs
- DirectoryNotFoundException.cs
- TextChange.cs
- DocumentXPathNavigator.cs
- BaseUriWithWildcard.cs
- PropertyMapper.cs
- DiscoveryClientOutputChannel.cs
- UdpSocketReceiveManager.cs
- BackgroundWorker.cs
- SoapParser.cs
- StatusBar.cs
- Normalization.cs
- Convert.cs
- AbsoluteQuery.cs
- PageStatePersister.cs
- SoapDocumentServiceAttribute.cs
- _Connection.cs
- CodeTypeOfExpression.cs
- KeyInstance.cs
- NativeWrapper.cs
- FileRecordSequenceCompletedAsyncResult.cs
- TextSimpleMarkerProperties.cs
- Native.cs
- SelectionHighlightInfo.cs
- Line.cs
- HtmlTable.cs
- DirtyTextRange.cs
- SqlParameterizer.cs
- CryptoHandle.cs
- DLinqColumnProvider.cs
- Timer.cs
- ComboBoxAutomationPeer.cs
- BuilderElements.cs
- SQLMoney.cs
- columnmapkeybuilder.cs
- HtmlInputButton.cs
- ReadOnlyDataSource.cs
- NullableConverter.cs
- IBuiltInEvidence.cs
- XmlSchemaValidator.cs
- SchemaCollectionPreprocessor.cs
- EventMappingSettingsCollection.cs
- BamlBinaryWriter.cs
- TemplateControlCodeDomTreeGenerator.cs
- CryptoHandle.cs
- Dump.cs
- SHA384Cng.cs