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
- KerberosReceiverSecurityToken.cs
- DynamicMethod.cs
- ButtonChrome.cs
- XmlSchemaIdentityConstraint.cs
- GroupItem.cs
- RadioButtonList.cs
- IArgumentProvider.cs
- X509PeerCertificateAuthentication.cs
- StreamWriter.cs
- DES.cs
- XamlRtfConverter.cs
- UiaCoreApi.cs
- ZoomComboBox.cs
- XNodeValidator.cs
- PrintController.cs
- AssertFilter.cs
- InkCollectionBehavior.cs
- controlskin.cs
- PolicyStatement.cs
- StylusPlugin.cs
- TypeContext.cs
- Ref.cs
- ListBindingConverter.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- ColorKeyFrameCollection.cs
- ServicePrincipalNameElement.cs
- BitmapEffectrendercontext.cs
- SqlStatistics.cs
- Expressions.cs
- DesignerActionVerbItem.cs
- DataTableReaderListener.cs
- EpmCustomContentSerializer.cs
- Oid.cs
- UserControlParser.cs
- ProcessHostServerConfig.cs
- ExecutionContext.cs
- LinkedResource.cs
- DependencyPropertyConverter.cs
- ContractMethodParameterInfo.cs
- Delay.cs
- Typography.cs
- UseAttributeSetsAction.cs
- MethodBody.cs
- Label.cs
- TemplateBaseAction.cs
- DiscoveryInnerClientAdhoc11.cs
- PolicyException.cs
- FunctionDetailsReader.cs
- WorkflowMarkupSerializationProvider.cs
- CompilerCollection.cs
- Exceptions.cs
- SimpleBitVector32.cs
- Accessible.cs
- httpapplicationstate.cs
- LinkLabel.cs
- Line.cs
- _ShellExpression.cs
- EmbeddedMailObject.cs
- BitmapImage.cs
- Manipulation.cs
- ValidationResult.cs
- SoapHeader.cs
- QilLoop.cs
- XmlSchemaGroupRef.cs
- PreservationFileReader.cs
- DiscriminatorMap.cs
- SqlSupersetValidator.cs
- FontStyle.cs
- XmlSchemaSequence.cs
- WebPartCatalogAddVerb.cs
- ShimAsPublicXamlType.cs
- StructureChangedEventArgs.cs
- MessageDesigner.cs
- ClientData.cs
- DbProviderFactoriesConfigurationHandler.cs
- Brush.cs
- SoundPlayer.cs
- SqlFactory.cs
- GotoExpression.cs
- IgnoreSection.cs
- DataRow.cs
- Dispatcher.cs
- TextAutomationPeer.cs
- ToolTipAutomationPeer.cs
- DetailsViewRow.cs
- PagePropertiesChangingEventArgs.cs
- ApplicationServiceManager.cs
- Matrix3DStack.cs
- HwndMouseInputProvider.cs
- LinqDataSourceInsertEventArgs.cs
- XmlSchemaInclude.cs
- MetadataProperty.cs
- ScriptReferenceBase.cs
- XmlReader.cs
- UpWmlPageAdapter.cs
- UnsignedPublishLicense.cs
- Aggregates.cs
- ProviderMetadata.cs
- PeerCustomResolverSettings.cs
- OleDbParameterCollection.cs