Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Tools / WSATConfig / Configuration / SafeIUnknown.cs / 1305376 / SafeIUnknown.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.Tools.ServiceModel.WsatConfig { 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 Microsoft.Tools.ServiceModel.WsatConfig { 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
- Button.cs
- DmlSqlGenerator.cs
- CopyNodeSetAction.cs
- XmlElement.cs
- DataGridViewCellConverter.cs
- TreeIterator.cs
- StyleSelector.cs
- Console.cs
- MetafileHeaderEmf.cs
- ExpandSegmentCollection.cs
- Imaging.cs
- RedistVersionInfo.cs
- RewritingPass.cs
- PackWebResponse.cs
- TraceSwitch.cs
- WebServiceEnumData.cs
- GeometryValueSerializer.cs
- AttributeAction.cs
- ExpressionEditorAttribute.cs
- DefinitionBase.cs
- BitmapEffectDrawingContextWalker.cs
- EntityDataSourceColumn.cs
- ParserHooks.cs
- CodePropertyReferenceExpression.cs
- ObjectNotFoundException.cs
- SourceSwitch.cs
- SrgsToken.cs
- DateTimeOffsetAdapter.cs
- HyperLink.cs
- coordinatorscratchpad.cs
- HttpApplicationStateWrapper.cs
- TimeSpanConverter.cs
- FieldToken.cs
- ModelUtilities.cs
- HyperLinkField.cs
- FastPropertyAccessor.cs
- InstalledVoice.cs
- CodeDelegateInvokeExpression.cs
- EntityDataSourceReferenceGroup.cs
- EdmToObjectNamespaceMap.cs
- ThumbAutomationPeer.cs
- AccessKeyManager.cs
- PrintDialogException.cs
- BitmapEffectDrawingContent.cs
- SecurityContextKeyIdentifierClause.cs
- MetadataPropertyAttribute.cs
- FullTextLine.cs
- AutoGeneratedFieldProperties.cs
- Serializer.cs
- QuaternionAnimation.cs
- TextBox.cs
- NullableLongSumAggregationOperator.cs
- ReachDocumentReferenceCollectionSerializer.cs
- GeneralTransform3D.cs
- MorphHelpers.cs
- CompensationHandlingFilter.cs
- OleDbWrapper.cs
- XmlAttribute.cs
- WindowHelperService.cs
- WindowsClaimSet.cs
- SqlExpressionNullability.cs
- Transform3DCollection.cs
- LogRestartAreaEnumerator.cs
- FontUnit.cs
- GridViewColumnHeader.cs
- ModifierKeysConverter.cs
- HtmlEmptyTagControlBuilder.cs
- Array.cs
- Vector3DAnimationBase.cs
- CodeParameterDeclarationExpression.cs
- NullableDoubleMinMaxAggregationOperator.cs
- XmlKeywords.cs
- DataGridViewRowPostPaintEventArgs.cs
- QfeChecker.cs
- MemoryFailPoint.cs
- ObjectAssociationEndMapping.cs
- AnnotationObservableCollection.cs
- Lease.cs
- IItemContainerGenerator.cs
- RightsManagementPermission.cs
- XamlPointCollectionSerializer.cs
- EntityDataSourceDataSelection.cs
- TextDecoration.cs
- Literal.cs
- WindowsSspiNegotiation.cs
- SHA256Managed.cs
- DeleteWorkflowOwnerCommand.cs
- EntityContainerAssociationSetEnd.cs
- DetailsViewDeleteEventArgs.cs
- CustomLineCap.cs
- DataBoundControlHelper.cs
- StyleSelector.cs
- DynamicResourceExtensionConverter.cs
- PathNode.cs
- OdbcConnectionOpen.cs
- TempFiles.cs
- AssemblyUtil.cs
- WebPartDisplayModeCancelEventArgs.cs
- PackagePart.cs
- SystemFonts.cs